<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>专家管理系统 - 关联信息管理</title>
    <#include "../../include/head-file.ftl"/>
    <link rel="stylesheet" href="${base}/static/ms-admin/4.7.2/css/index.css">
    <!-- 引入ECharts JS库 -->
    <script src="${base}/static/plugins/echarts/echarts.min.js"></script>
    <style>
        .ms-admin-relation-container {
            height: calc(100vh - 60px);
        }
        
        .ms-container {
            padding: 0;
            background: transparent;
            display: flex;
            flex-direction: column;
        }
        
        .ms-header {
            padding: 0;
            margin-bottom: 10px;
            background-color: #fff;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        
        .ms-header-left {
            display: flex;
            align-items: center;
        }
        
        .ms-header-title {
            font-size: 20px;
            font-weight: 600;
            color: #303133;
            margin: 0;
            position: relative;
            padding-left: 16px;
            letter-spacing: 0.5px;
            display: flex;
            align-items: center;
        }
        
        .ms-header-title:before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 22px;
            background: linear-gradient(to bottom, #409EFF, #67c23a);
            border-radius: 2px;
        }
        
        .ms-header-subtitle {
            color: #909399;
            font-size: 14px;
            font-weight: normal;
            margin-left: 15px;
            font-style: italic;
            opacity: 0.9;
        }
        
        .loading-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 300px;
        }
        
        .loading-spinner {
            margin-top: 20px;
            font-size: 30px;
        }
        
        .empty-container {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 300px;
        }
        
        .info-container {
            margin-bottom: 20px;
        }
        
        .expert-card, .project-card, .relation-chart-card, .project-detail-card, .company-card {
            margin-bottom: 20px;
            transition: box-shadow 0.3s, transform 0.3s;
        }
        
        /* 添加卡片悬停效果 */
        .expert-card:hover, .project-card:hover, .relation-chart-card:hover, 
        .project-detail-card:hover, .company-card:hover {
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
            transform: translateY(-2px);
        }
        
        /* 添加表格行悬停效果 */
        .el-table__row {
            transition: background-color 0.3s, transform 0.2s;
        }
        
        .el-table__row:hover {
            transform: translateY(-1px);
            background-color: #ecf5ff !important;
        }
        
        /* 卡片标题样式 */
        .section-title {
            position: relative;
            padding-left: 12px;
            font-size: 16px;
            font-weight: 500;
            color: #333;
            margin-bottom: 15px;
            border-left: 3px solid #409EFF;
        }
        
        .section-title:after {
            content: '';
            display: block;
            height: 1px;
            background: linear-gradient(to right, 
                #dcdfe6 0%, #dcdfe6 10%, 
                #c0c4cc 45%, #c0c4cc 55%, 
                #dcdfe6 90%, #dcdfe6 100%);
            margin-top: 8px;
        }
        
        /* 公司标题样式 */
        .company-title {
            font-weight: 500;
            color: #409EFF;
        }
        
        /* 公司卡片内的每个项目样式 */
        .company-item {
            margin-bottom: 15px;
            padding-bottom: 15px;
        }
        
        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .info-item {
            margin-bottom: 10px;
        }
        
        .label {
            font-weight: bold;
            margin-right: 5px;
            color: #606266;
        }
        
        .empty-data {
            padding: 40px 0;
        }
        
        .relation-chart {
            width: 100%;
            height: 500px;
            position: relative;
        }
        
        /* 图谱控制按钮样式 */
        .chart-controls {
            position: absolute;
            top: 10px;
            right: 10px;
            z-index: 100;
            display: flex;
            gap: 5px;
        }
        
        .chart-controls .el-button {
            padding: 6px;
            border-radius: 50%;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            background-color: #409EFF;
            color: white;
            border: none;
        }
        
        .chart-controls .el-button:hover {
            background-color: #66b1ff;
        }
        
        /* 图谱提示框样式 */
        .chart-tooltip {
            background: rgba(255,255,255,0.95) !important;
            border-radius: 4px !important;
            box-shadow: 0 3px 6px rgba(0,0,0,0.15) !important;
            padding: 10px !important;
            border: 1px solid #ebeef5 !important;
        }
        
        /* 三表格布局样式 */
        .three-table-layout {
            display: flex;
            flex-direction: column;
            gap: 20px;
        }
        
        .table-section {
            border: 1px solid #EBEEF5;
            border-radius: 4px;
            overflow: hidden;
            box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
            background-color: #ffffff;
        }
        
        .table-section-header {
            background-color: #f5f7fa;
            padding: 12px 15px;
            border-bottom: 1px solid #EBEEF5;
            font-weight: bold;
            font-size: 16px;
            color: #303133;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .table-section-body {
            padding: 15px;
        }
        
        .info-table {
            width: 100%;
            border-collapse: collapse;
        }
        
        .info-table td {
            padding: 8px 12px;
            border-bottom: 1px solid #EBEEF5;
        }
        
        .info-table td.label-cell {
            width: 120px;
            color: #606266;
            font-weight: bold;
            background-color: #fafafa;
        }
        
        .info-table td.value-cell {
            color: #303133;
        }
        
        .expert-table-container {
            margin-bottom: 20px;
            display: flex;
            flex-direction: column;
        }
        
        .ms-table-pagination {
            padding: 10px 0;
        }
        
        /* 新增样式 */
        .el-table .cell {
            padding-left: 10px;
            padding-right: 10px;
            line-height: 23px;
            white-space: normal;
            word-break: break-word;
        }
        
        .el-table--striped .el-table__body tr.el-table__row--striped td {
            background-color: #fafafa;
        }
        
        /* 增强表格行悬停效果 */
        .el-table--enable-row-hover .el-table__body tr:hover>td {
            background-color: #f5f7fa;
            margin-bottom: 5px;
        }
        
        .el-button--text {
            padding: 3px 0;
            margin: 0 5px;
        }
        
        .el-button [class*=el-icon-]+span {
            margin-left: 3px;
        }
        
        /* 自定义按钮样式 */
        .operation-buttons {
            display: flex;
            justify-content: center;
            gap: 5px;
        }
        
        .ms-btn {
            padding: 5px 10px;
            border-radius: 4px;
            border: none;
            cursor: pointer;
            font-size: 12px;
            color: #fff;
        }
        
        .ms-btn-primary {
            background-color: #409eff;
        }
        
        .ms-btn-info {
            background-color: #909399;
        }
        
        .ms-btn-warning {
            background-color: #e6a23c;
        }
        
        .ms-btn:hover {
            opacity: 0.8;
        }
        
        /* 分页样式 */
        .ms-pagination {
            padding: 20px 0;
            text-align: right;
            margin-top: 15px;
            margin-bottom: 15px;
            background-color: #ffffff;
            border-top: 1px solid #ebeef5;
        }
        
        /* 添加数据导入按钮样式 */
        .data-import-button {
            margin-left: 15px;
            margin-right: 20px;
        }
        
        /* 操作按钮组样式 */
        .operation-buttons {
            display: flex;
            align-items: center;
        }
        
        /* 查询按钮样式 */
        .search-buttons {
            display: flex;
            gap: 10px;
        }
        
        /* 图表详情通知样式 */
        .relation-details-notification {
            width: 350px !important;
            max-width: 350px;
        }
        
        .relation-details-notification .el-notification__content {
            max-height: 500px;
            overflow-y: auto;
            text-align: left;
        }
        
        /* 图表悬停提示框样式 */
        .node-tooltip {
            background-color: rgba(255, 255, 255, 0.95) !important;
            border: 1px solid #e4e7ed !important;
            border-radius: 4px !important;
            padding: 12px !important;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
            max-width: 350px !important;
            font-size: 14px !important;
        }
        
        .tooltip-title {
            font-weight: bold;
            color: #409EFF;
            border-bottom: 1px solid #ebeef5;
            padding-bottom: 8px;
            margin-bottom: 10px;
        }
        
        .tooltip-content {
            color: #606266;
        }
        
        .tooltip-label {
            color: #909399;
            display: inline-block;
            min-width: 70px;
            margin-right: 10px;
        }
        
        .tooltip-value {
            color: #303133;
            font-weight: 500;
        }
        
        .tooltip-row {
            margin-bottom: 5px;
        }
        
        /* 通用按钮样式 - 选中ECharts生成的所有按钮 */
        .ec-extension-echarts .ec-legend-item button,
        .ec-extension-echarts button.ec-legend-all,
        .ec-extension-echarts button.ec-legend-inverse,
        .ec-extension-echarts li.ec-legend-item button,
        div[_echarts_instance_] button,
        .ec-legend button,
        .echarts-legend-selector button {
            border: 1px solid #dcdfe6 !important;
            background-color: #ffffff !important;
            color: #606266 !important;
            margin: 0 4px !important;
            padding: 4px 8px !important;
            border-radius: 4px !important;
            cursor: pointer !important;
            transition: all 0.3s !important;
            font-size: 12px !important;
        }
        
        /* 选中按钮样式 */
        .ec-extension-echarts .ec-legend-item button[class*="active"],
        .ec-extension-echarts button.ec-legend-all[class*="active"],
        .ec-extension-echarts button.ec-legend-inverse[class*="active"],
        .ec-extension-echarts li.ec-legend-item button[class*="active"],
        div[_echarts_instance_] button[class*="active"],
        .ec-legend button[class*="active"],
        .echarts-legend-selector button[class*="active"],
        .ec-extension-echarts .ec-legend-item button.ec-legend-active,
        div[_echarts_instance_] button.ec-legend-active,
        .ec-legend button.ec-legend-active,
        .echarts-legend-selector button.ec-legend-active {
            border-color: #409EFF !important;
            background-color: #409EFF !important;
            color: #ffffff !important;
        }
    </style>
</head>
<body>
<div id="app" class="ms-admin-relation-container" v-cloak>
    <div class="ms-header">
        <div class="ms-header-left">
            <h1 class="ms-header-title">
                关联查询
            </h1>
            <span class="ms-header-subtitle">便捷高效的数据检索系统</span>
        </div>
        <div class="operation-buttons">
            <el-button type="primary" @click="showAddDataDialog">添加数据</el-button>
            <el-button class="data-import-button" type="success" @click="handleDataImport">数据导入</el-button>
            <el-button type="warning" @click="showManagementDialog">管理</el-button>
        </div>
    </div>
    <el-main class="ms-container">
        <!-- 专家列表表格 - 使用系统原始样式 -->
        <div class="expert-table-container">
            <!-- Add search bar here -->
            <div style="margin-bottom: 20px; display: flex;">
                <el-input
                    v-model="searchKeyword"
                    placeholder="输入专家编号、姓名或研究方向搜索"
                    style="width: 300px;"
                    clearable>
                </el-input>
                <el-button type="primary" @click="searchExperts" style="margin-left: 10px;">搜索</el-button>
                <el-button @click="resetSearch" style="margin-left: 10px;">重置</el-button>
            </div>
            <el-table
                :data="expertList"
                v-loading="tableLoading"
                stripe
                border
                :max-height="tableMaxHeight"
                style="width: 100%">
                <el-table-column
                    prop="expertCode"
                    label="专家编号"
                    width="110">
                </el-table-column>
                <el-table-column
                    prop="name"
                    label="专家姓名"
                    width="110">
                </el-table-column>
                <el-table-column
                    prop="college"
                    label="所属学院"
                    width="160">
                </el-table-column>
                <el-table-column
                    prop="researchKeywords"
                    label="研究方向"
                    min-width="220"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column
                    prop="title"
                    label="职称"
                    width="110">
                </el-table-column>
                <el-table-column
                    label="操作"
                    align="center"
                    width="210">
                    <template #default="scope">
                        <el-button size="mini" type="text" @click="handleQueryRelations(scope.row.expertCode)">查看</el-button>
                        <el-link type="primary" :underline="false" @click="editRelations(scope.row)">综合编辑</el-link>
                        <el-button size="mini" type="text" style="color: #F56C6C;" @click="handleDeleteConfirm(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!-- 分页组件 - 修复版 -->
            <div style="display: flex; justify-content: end; background: white; padding: 10px 0px">
                <el-pagination
                    v-model:current-page="currentPage"
                    v-model:page-size="pageSize"
                    :page-sizes="[10, 20, 50, 100]"
                    :total="total"
                    layout="total, sizes, prev, pager, next, jumper"
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                >
                </el-pagination>
        </div>
        
        <!-- 加载状态 -->
        <div v-if="loading" class="loading-container">
            <el-alert
              title="正在加载数据，请稍候..."
              type="info"
              center
              :closable="false">
            </el-alert>
            <div class="loading-spinner">
                <i class="el-icon-loading"></i>
            </div>
        </div>
        
        <!-- 关联信息展示 - 三表格布局 -->
        <div v-if="!loading && expertInfo.expertCode" class="three-table-layout">
            <!-- 专家基本信息表 -->
                <div class="table-section" v-if="expertInfo.expertCode">
                <div class="table-section-header">
                    <span>专家基本信息</span>
                </div>
                <div class="table-section-body">
                    <table class="info-table">
                        <tr>
                            <td class="label-cell">专家编号</td>
                            <td class="value-cell">{{ expertInfo.expertCode }}</td>
                            <td class="label-cell">姓名</td>
                            <td class="value-cell">{{ expertInfo.name }}</td>
                            <td class="label-cell">性别</td>
                            <td class="value-cell">{{ expertInfo.gender }}</td>
                        </tr>
                        <tr>
                            <td class="label-cell">年龄</td>
                            <td class="value-cell">{{ expertInfo.age }}</td>
                            <td class="label-cell">职称/头衔</td>
                            <td class="value-cell">{{ expertInfo.title }}</td>
                            <td class="label-cell">最高学历</td>
                            <td class="value-cell">{{ expertInfo.highestEducation }}</td>
                        </tr>
                        <tr>
                            <td class="label-cell">一级学科</td>
                            <td class="value-cell">{{ expertInfo.firstLevelDiscipline }}</td>
                            <td class="label-cell">二级学科</td>
                            <td class="value-cell">{{ expertInfo.secondLevelDiscipline }}</td>
                            <td class="label-cell">校内/外</td>
                            <td class="value-cell">{{ expertInfo.insideOutside }}</td>
                        </tr>
                        <tr>
                            <td class="label-cell">所属学院</td>
                            <td class="value-cell">{{ expertInfo.college }}</td>
                            <td class="label-cell">知识产权</td>
                            <td class="value-cell">{{ expertInfo.ipOwnership }}</td>
                            <td class="label-cell">社会职务</td>
                            <td class="value-cell">{{ expertInfo.socialPositions }}</td>
                        </tr>
                        <tr>
                            <td class="label-cell">研究方向</td>
                            <td class="value-cell" colspan="5">{{ expertInfo.researchKeywords }}</td>
                        </tr>
                        <tr>
                            <td class="label-cell">联系方式</td>
                            <td class="value-cell" colspan="2">{{ expertInfo.contact }}</td>
                            <td class="label-cell">备注</td>
                            <td class="value-cell" colspan="2">{{ expertInfo.remarks }}</td>
                        </tr>
                    </table>
                </div>
            </div>
            
            <!-- 关联项目信息表 -->
            <div class="table-section" v-if="relatedProjects.length > 0">
                <div class="table-section-header">
                    <span>关联项目信息</span>
                </div>
                <div class="table-section-body">
                    <el-table
                        :data="relatedProjects"
                        border
                        stripe
                        style="width: 100%"
                        @row-click="handleProjectRowClick">
                        <el-table-column prop="projectCode" label="项目编号" width="100"></el-table-column>
                        <el-table-column prop="projectName" label="项目名称" min-width="180"></el-table-column>
                        <el-table-column prop="department" label="所属部门" width="120"></el-table-column>
                        <el-table-column prop="projectType" label="项目类型" width="100"></el-table-column>
                        <el-table-column prop="techMaturity" label="技术成熟度" width="130"></el-table-column>
                        <el-table-column prop="relatedRole" label="参与角色" width="100"></el-table-column>
                        <el-table-column label="合作倾向" width="180">
                            <template #default="scope">
                                {{ scope.row.cooperationTendency || '无' }}
                            </template>
                        </el-table-column>
                    </el-table>
                    
                    <!-- 项目详情 -->
                    <div v-if="selectedProject.projectCode" style="margin-top: 15px; border-top: 1px dashed #EBEEF5; padding-top: 15px;">
                        <h4 style="color: #409EFF; font-size: 14px; margin-bottom: 10px;">项目详情：{{ selectedProject.projectName }}</h4>
                        <table class="info-table">
                            <tr>
                                <td class="label-cell">核心技术</td>
                                <td class="value-cell">{{ selectedProject.coreTechKeywords }}</td>
                                <td class="label-cell">应用行业</td>
                                <td class="value-cell">{{ selectedProject.applicationIndustry }}</td>
                            </tr>
                            <tr>
                                <td class="label-cell">市场阶段</td>
                                <td class="value-cell">{{ selectedProject.marketStage }}</td>
                                <td class="label-cell">转化方式</td>
                                <td class="value-cell">{{ selectedProject.transformationMode }}</td>
                            </tr>
                            <tr>
                                <td class="label-cell">知识产权</td>
                                <td class="value-cell">{{ selectedProject.ipDetails }}</td>
                                <td class="label-cell">项目预算</td>
                                <td class="value-cell">{{ selectedProject.budget }}</td>
                            </tr>
                            <tr>
                                <td class="label-cell">备注</td>
                                <td class="value-cell" colspan="3">{{ selectedProject.remarks }}</td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
                <div class="table-section" v-else-if="expertInfo.expertCode">
                <div class="table-section-header">
                    <span>关联项目信息</span>
                </div>
                <div class="table-section-body">
                    <el-empty description="暂无关联项目信息"></el-empty>
                </div>
            </div>
            
            <!-- 关联企业信息表 -->
            <div class="table-section" v-if="relatedCompanies.length > 0">
                <div class="table-section-header">
                    <span>关联企业信息</span>
                </div>
                <div class="table-section-body">
                    <el-table
                        :data="relatedCompanies"
                        border
                        stripe
                        @row-click="handleCompanyRowClick"
                        style="width: 100%">
                        <el-table-column prop="companyCode" label="企业编号" width="100"></el-table-column>
                        <el-table-column prop="companyName" label="企业名称" min-width="150"></el-table-column>
                        <el-table-column prop="companyType" label="企业类型" width="120"></el-table-column>
                        <el-table-column prop="industryPrimary" label="行业(一级)" width="120"></el-table-column>
                        <el-table-column prop="industrySecondary" label="行业(二级)" width="120"></el-table-column>
                        <el-table-column prop="contactPerson" label="联系人" width="100"></el-table-column>
                        <el-table-column prop="cooperationStatus" label="合作状态" width="100"></el-table-column>
                    </el-table>
                    
                    <!-- 企业详情 -->
                    <div v-if="selectedCompany.companyCode" style="margin-top: 15px; border-top: 1px dashed #EBEEF5; padding-top: 15px;">
                        <h4 style="color: #409EFF; font-size: 14px; margin-bottom: 10px;">企业详细信息：{{ selectedCompany.companyName }}</h4>
                        <table class="info-table">
                            <tr>
                                <td class="label-cell">业务关键词</td>
                                <td class="value-cell">{{ selectedCompany.businessKeywords }}</td>
                                <td class="label-cell">合作需求</td>
                                <td class="value-cell">{{ selectedCompany.cooperationType }}</td>
                            </tr>
                            <tr>
                                <td class="label-cell">需求技术</td>
                                <td class="value-cell">{{ selectedCompany.requiredTechField }}</td>
                                <td class="label-cell">需求专家</td>
                                <td class="value-cell">{{ selectedCompany.requiredExpertTitle }}</td>
                            </tr>
                            <tr>
                                <td class="label-cell">对接专家</td>
                                <td class="value-cell">{{ selectedCompany.matchedExpertCodes }}</td>
                                <td class="label-cell">合作历史</td>
                                <td class="value-cell">{{ selectedCompany.cooperationHistory }}</td>
                            </tr>
                            <tr>
                                <td class="label-cell">备注</td>
                                <td class="value-cell" colspan="3">{{ selectedCompany.remarks }}</td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
                <div class="table-section" v-else-if="expertInfo.expertCode">
                <div class="table-section-header">
                    <span>关联企业信息</span>
                </div>
                <div class="table-section-body">
                    <el-empty description="暂无关联企业信息"></el-empty>
                </div>
            </div>
            
            <!-- 项目关系图谱 -->
                <div class="table-section" v-if="expertInfo.expertCode">
                <div class="table-section-header">
                    <span>专家关系图谱</span>
                </div>
                <div class="table-section-body">
                    <div id="relationChart" class="relation-chart" style="height: 550px;">
                        <div class="chart-controls">
                            <el-button size="mini" icon="el-icon-zoom-in" circle @click="zoomIn" title="放大"></el-button>
                            <el-button size="mini" icon="el-icon-zoom-out" circle @click="zoomOut" title="缩小"></el-button>
                            <el-button size="mini" icon="el-icon-refresh" circle @click="resetChart" title="重置"></el-button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </el-main>
    
    <!-- 专家详情弹窗 -->
    <el-dialog title="专家详情" :visible.sync="expertDetailsVisible" width="70%">
        <el-descriptions :column="2" border>
            <el-descriptions-item label="专家编号">{{ expertInfoDetails.expertCode }}</el-descriptions-item>
            <el-descriptions-item label="专家姓名">{{ expertInfoDetails.name }}</el-descriptions-item>
            <el-descriptions-item label="性别">{{ expertInfoDetails.gender }}</el-descriptions-item>
            <el-descriptions-item label="年龄">{{ expertInfoDetails.age }}</el-descriptions-item>
            <el-descriptions-item label="职称/头衔">{{ expertInfoDetails.title }}</el-descriptions-item>
            <el-descriptions-item label="最高学历">{{ expertInfoDetails.highestEducation }}</el-descriptions-item>
            <el-descriptions-item label="一级学科">{{ expertInfoDetails.firstLevelDiscipline }}</el-descriptions-item>
            <el-descriptions-item label="二级学科">{{ expertInfoDetails.secondLevelDiscipline }}</el-descriptions-item>
            <el-descriptions-item label="所属学院">{{ expertInfoDetails.college }}</el-descriptions-item>
            <el-descriptions-item label="校内/外标识">{{ expertInfoDetails.insideOutside }}</el-descriptions-item>
            <el-descriptions-item label="研究方向关键词" :span="2">{{ expertInfoDetails.researchKeywords }}</el-descriptions-item>
            <el-descriptions-item label="成果类型">{{ expertInfoDetails.achievementType }}</el-descriptions-item>
            <el-descriptions-item label="知识产权数">{{ expertInfoDetails.ipOwnership }}</el-descriptions-item>
            <el-descriptions-item label="社会职务数">{{ expertInfoDetails.socialPositions }}</el-descriptions-item>
            <el-descriptions-item label="纵向项目数">{{ expertInfoDetails.verticalProjects }}</el-descriptions-item>
            <el-descriptions-item label="横向项目数">{{ expertInfoDetails.horizontalProjects }}</el-descriptions-item>
            <el-descriptions-item label="联系方式">{{ expertInfoDetails.contact }}</el-descriptions-item>
            <el-descriptions-item label="备注" :span="2">{{ expertInfoDetails.remarks }}</el-descriptions-item>
        </el-descriptions>
    </el-dialog>
    
    <!-- 项目详情弹窗 -->
    <el-dialog title="项目详情" :visible.sync="projectDetailsVisible" width="70%">
        <el-descriptions :column="2" border>
            <el-descriptions-item label="项目编号">{{ projectDetails.projectCode }}</el-descriptions-item>
            <el-descriptions-item label="项目名称">{{ projectDetails.projectName }}</el-descriptions-item>
            <el-descriptions-item label="所属部门">{{ projectDetails.department }}</el-descriptions-item>
            <el-descriptions-item label="负责人编号">{{ projectDetails.leaderCode }}</el-descriptions-item>
            <el-descriptions-item label="参与专家">{{ projectDetails.participantExperts }}</el-descriptions-item>
            <el-descriptions-item label="项目类型">{{ projectDetails.projectType }}</el-descriptions-item>
            <el-descriptions-item label="技术成熟度">{{ projectDetails.techMaturity }}</el-descriptions-item>
            <el-descriptions-item label="核心技术关键词">{{ projectDetails.coreTechKeywords }}</el-descriptions-item>
            <el-descriptions-item label="应用行业">{{ projectDetails.applicationIndustry }}</el-descriptions-item>
            <el-descriptions-item label="市场化阶段">{{ projectDetails.marketStage }}</el-descriptions-item>
            <el-descriptions-item label="知识产权详情">{{ projectDetails.ipDetails }}</el-descriptions-item>
            <el-descriptions-item label="合作企业倾向">{{ projectDetails.cooperationTendency }}</el-descriptions-item>
            <el-descriptions-item label="预算">{{ projectDetails.budget }}</el-descriptions-item>
            <el-descriptions-item label="联系方式">{{ projectDetails.contact }}</el-descriptions-item>
            <el-descriptions-item label="备注" :span="2">{{ projectDetails.remarks }}</el-descriptions-item>
        </el-descriptions>
    </el-dialog>
    
    <!-- 企业详情弹窗 -->
    <el-dialog title="企业详情" :visible.sync="companyDetailsVisible" width="70%">
        <el-descriptions :column="2" border>
            <el-descriptions-item label="企业编号">{{ companyDetails.companyCode }}</el-descriptions-item>
            <el-descriptions-item label="企业名称">{{ companyDetails.companyName }}</el-descriptions-item>
            <el-descriptions-item label="企业类型">{{ companyDetails.companyType }}</el-descriptions-item>
            <el-descriptions-item label="所属行业(一级)">{{ companyDetails.industryPrimary }}</el-descriptions-item>
            <el-descriptions-item label="所属行业(二级)">{{ companyDetails.industrySecondary }}</el-descriptions-item>
            <el-descriptions-item label="注册地址">{{ companyDetails.registrationAddress }}</el-descriptions-item>
            <el-descriptions-item label="联系人">{{ companyDetails.contactPerson }}</el-descriptions-item>
            <el-descriptions-item label="联系方式">{{ companyDetails.contactInfo }}</el-descriptions-item>
            <el-descriptions-item label="主营业务关键词">{{ companyDetails.businessKeywords }}</el-descriptions-item>
            <el-descriptions-item label="合作需求类型">{{ companyDetails.cooperationType }}</el-descriptions-item>
            <el-descriptions-item label="需求技术领域">{{ companyDetails.requiredTechField }}</el-descriptions-item>
            <el-descriptions-item label="需求专家职称">{{ companyDetails.requiredExpertTitle }}</el-descriptions-item>
            <el-descriptions-item label="合作状态">{{ companyDetails.cooperationStatus }}</el-descriptions-item>
            <el-descriptions-item label="合作历史" :span="2">{{ companyDetails.cooperationHistory }}</el-descriptions-item>
            <el-descriptions-item label="备注" :span="2">{{ companyDetails.remarks }}</el-descriptions-item>
        </el-descriptions>
    </el-dialog>
    
    <!-- 添加数据对话框 -->
    <el-dialog 
        title="添加数据" 
        :visible.sync="addDataVisible" 
        width="70%" 
        :close-on-click-modal="false"
        :before-close="closeAddDataDialog">
        <el-tabs v-model="activeDataType">
            <el-tab-pane label="添加专家" name="expert">
                <el-form :model="newExpertForm" ref="expertForm" label-width="120px" :rules="expertRules">
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="专家编号" prop="expertCode">
                                <el-input v-model="newExpertForm.expertCode" placeholder="如：ZJ-001"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="姓名" prop="name">
                                <el-input v-model="newExpertForm.name"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="性别" prop="gender">
                                <el-select v-model="newExpertForm.gender" placeholder="请选择">
                                    <el-option label="男" value="男"></el-option>
                                    <el-option label="女" value="女"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="年龄" prop="age">
                                <el-input-number v-model="newExpertForm.age" :min="0" :max="120"></el-input-number>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="职称/头衔" prop="title">
                                <el-input v-model="newExpertForm.title"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="最高学历" prop="highestEducation">
                                <el-select v-model="newExpertForm.highestEducation" placeholder="请选择">
                                    <el-option label="博士" value="博士"></el-option>
                                    <el-option label="硕士" value="硕士"></el-option>
                                    <el-option label="本科" value="本科"></el-option>
                                    <el-option label="其他" value="其他"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="一级学科" prop="firstLevelDiscipline">
                                <el-input v-model="newExpertForm.firstLevelDiscipline"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="二级学科" prop="secondLevelDiscipline">
                                <el-input v-model="newExpertForm.secondLevelDiscipline"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="所属学院" prop="college">
                                <el-input v-model="newExpertForm.college"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="校内/外标识" prop="insideOutside">
                                <el-select v-model="newExpertForm.insideOutside" placeholder="请选择">
                                    <el-option label="校内" value="校内"></el-option>
                                    <el-option label="校外" value="校外"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="知识产权持有量" prop="ipOwnership">
                                <el-input v-model="newExpertForm.ipOwnership"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="社会职务" prop="socialPositions">
                                <el-input v-model="newExpertForm.socialPositions"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="纵向项目数" prop="verticalProjects">
                                <el-input v-model="newExpertForm.verticalProjects"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="横向项目数" prop="horizontalProjects">
                                <el-input v-model="newExpertForm.horizontalProjects"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-form-item label="研究方向关键词" prop="researchKeywords">
                        <el-input v-model="newExpertForm.researchKeywords" type="textarea" rows="2" placeholder="请输入3-5个关键词，用逗号分隔"></el-input>
                    </el-form-item>
                    
                    <el-form-item label="代表性成果类型" prop="achievementType">
                        <el-input v-model="newExpertForm.achievementType"></el-input>
                    </el-form-item>
                    
                    <el-form-item label="联系方式" prop="contact">
                        <el-input v-model="newExpertForm.contact"></el-input>
                    </el-form-item>
                    
                    <el-form-item label="备注" prop="remarks">
                        <el-input v-model="newExpertForm.remarks" type="textarea" rows="3"></el-input>
                    </el-form-item>
                </el-form>
            </el-tab-pane>
            
            <el-tab-pane label="添加项目" name="project">
                <el-form :model="newProjectForm" ref="projectForm" label-width="120px" :rules="projectRules">
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="项目编号" prop="projectCode">
                                <el-input v-model="newProjectForm.projectCode" placeholder="如：Z-001"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="16">
                            <el-form-item label="项目名称" prop="projectName">
                                <el-input v-model="newProjectForm.projectName"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="所属部门" prop="department">
                                <el-input v-model="newProjectForm.department"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="负责人编号" prop="leaderCode">
                                <el-input v-model="newProjectForm.leaderCode" placeholder="如：ZJ-001"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="项目类型" prop="projectType">
                                <el-input v-model="newProjectForm.projectType" placeholder="如：产品类/服务类"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="技术成熟度" prop="techMaturity">
                                <el-input v-model="newProjectForm.techMaturity" placeholder="如：TRL5"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="市场化阶段" prop="marketStage">
                                <el-input v-model="newProjectForm.marketStage"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="转化方式" prop="transformationMode">
                                <el-input v-model="newProjectForm.transformationMode"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-form-item label="参与专家编号" prop="participantExperts">
                        <el-input v-model="newProjectForm.participantExperts" placeholder="多个专家用逗号分隔，如：ZJ-001, ZJ-002"></el-input>
                    </el-form-item>
                    
                    <el-form-item label="核心技术关键词" prop="coreTechKeywords">
                        <el-input v-model="newProjectForm.coreTechKeywords" type="textarea" rows="2"></el-input>
                    </el-form-item>
                    
                    <el-form-item label="应用行业" prop="applicationIndustry">
                        <el-input v-model="newProjectForm.applicationIndustry"></el-input>
                    </el-form-item>
                    
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="知识产权详情" prop="ipDetails">
                                <el-input v-model="newProjectForm.ipDetails"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="预算需求" prop="budget">
                                <el-input v-model="newProjectForm.budget"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-form-item label="合作企业意向" prop="cooperationTendency">
                        <el-input v-model="newProjectForm.cooperationTendency" placeholder="企业编号，多个用逗号分隔"></el-input>
                    </el-form-item>
                    
                    <el-form-item label="联系方式" prop="contact">
                        <el-input v-model="newProjectForm.contact"></el-input>
                    </el-form-item>
                    
                    <el-form-item label="备注" prop="remarks">
                        <el-input v-model="newProjectForm.remarks" type="textarea" rows="3"></el-input>
                    </el-form-item>
                </el-form>
            </el-tab-pane>
            
            <el-tab-pane label="添加企业" name="company">
                <el-form :model="newCompanyForm" ref="companyForm" label-width="120px" :rules="companyRules">
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="企业编号" prop="companyCode">
                                <el-input v-model="newCompanyForm.companyCode" placeholder="如：QY-001"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="16">
                            <el-form-item label="企业名称" prop="companyName">
                                <el-input v-model="newCompanyForm.companyName"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="企业类型" prop="companyType">
                                <el-input v-model="newCompanyForm.companyType"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="所属行业(一级)" prop="industryPrimary">
                                <el-input v-model="newCompanyForm.industryPrimary"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="所属行业(二级)" prop="industrySecondary">
                                <el-input v-model="newCompanyForm.industrySecondary"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="注册地址" prop="registrationAddress">
                                <el-input v-model="newCompanyForm.registrationAddress"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="联系人" prop="contactPerson">
                                <el-input v-model="newCompanyForm.contactPerson"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="联系方式" prop="contactInfo">
                                <el-input v-model="newCompanyForm.contactInfo"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-form-item label="主营业务关键词" prop="businessKeywords">
                        <el-input v-model="newCompanyForm.businessKeywords" type="textarea" rows="2"></el-input>
                    </el-form-item>
                    
                    <el-row :gutter="20">
                        <el-col :span="12">
                            <el-form-item label="合作需求类型" prop="cooperationType">
                                <el-input v-model="newCompanyForm.cooperationType"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="需求技术领域" prop="requiredTechField">
                                <el-input v-model="newCompanyForm.requiredTechField"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-row :gutter="20">
                        <el-col :span="8">
                            <el-form-item label="需求专家职称" prop="requiredExpertTitle">
                                <el-input v-model="newCompanyForm.requiredExpertTitle"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="对接专家编号" prop="matchedExpertCodes">
                                <el-input v-model="newCompanyForm.matchedExpertCodes" placeholder="多个专家用逗号分隔"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="合作状态" prop="cooperationStatus">
                                <el-input v-model="newCompanyForm.cooperationStatus"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    
                    <el-form-item label="合作历史项目" prop="cooperationHistory">
                        <el-input v-model="newCompanyForm.cooperationHistory" placeholder="项目编号，多个用逗号分隔"></el-input>
                    </el-form-item>
                    
                    <el-form-item label="备注" prop="remarks">
                        <el-input v-model="newCompanyForm.remarks" type="textarea" rows="3"></el-input>
                    </el-form-item>
                </el-form>
            </el-tab-pane>
        </el-tabs>
        <div slot="footer" class="dialog-footer">
            <el-button @click="closeAddDataDialog">取 消</el-button>
            <el-button type="primary" @click="submitAddData" :loading="submitLoading">确 定</el-button>
        </div>
    </el-dialog>
    
    <!-- 删除确认弹窗 -->
    <el-dialog
        title="删除确认"
        :visible.sync="deleteConfirmVisible"
        width="40%"
        :close-on-click-modal="false">
        <div class="delete-confirm-content">
            <i class="el-icon-warning" style="color: #E6A23C; font-size: 24px; margin-right: 10px;"></i>
            <span>确定要删除专家"<strong>{{ expertToDelete.name }}</strong>"及其所有关联信息吗？</span>
        </div>
        <div class="delete-confirm-detail" style="margin-top: 20px; padding: 10px; background: #f8f8f8; border-radius: 4px;">
            <p style="color: #F56C6C; margin: 0;">此操作将同时删除：</p>
            <ul style="margin: 10px 0; padding-left: 20px;">
                <li>该专家的基本信息</li>
                <li>与该专家关联的所有项目信息</li>
                <li>与该专家关联的所有企业信息</li>
            </ul>
            <p style="color: #F56C6C; font-weight: bold; margin: 0;">此操作不可恢复，请谨慎操作！</p>
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button @click="deleteConfirmVisible = false">取 消</el-button>
            <el-button type="danger" @click="confirmDelete" :loading="deleteLoading">确定删除</el-button>
        </span>
    </el-dialog>
    
    <!-- 管理功能对话框 -->
    <el-dialog
        title="数据管理"
        :visible.sync="managementDialogVisible"
        width="80%"
        :close-on-click-modal="false">
        <el-tabs v-model="activeManagementTab">
            <el-tab-pane label="企业信息管理" name="company">
                <div style="margin-bottom: 20px;">
                    <el-input
                        v-model="companySearchKeyword"
                        placeholder="输入企业名称或编号搜索"
                        style="width: 300px;"
                        clearable>
                    </el-input>
                    <el-button type="primary" @click="searchCompany" style="margin-left: 10px;">搜索</el-button>
                    <el-button @click="resetCompanySearch" style="margin-left: 10px;">重置</el-button>
                </div>
                <el-table
                    :data="companyList"
                    v-loading="companyLoading"
                    stripe
                    border
                    style="width: 100%">
                    <el-table-column prop="companyCode" label="企业编号" width="120"></el-table-column>
                    <el-table-column prop="companyName" label="企业名称" min-width="200"></el-table-column>
                    <el-table-column prop="companyType" label="企业类型" width="120"></el-table-column>
                    <el-table-column prop="industryPrimary" label="所属行业" width="120"></el-table-column>
                    <el-table-column prop="contactPerson" label="联系人" width="100"></el-table-column>
                    <el-table-column prop="contactInfo" label="联系方式" width="150"></el-table-column>
                    <el-table-column label="操作" width="180" align="center">
                        <template #default="scope">
                            <el-button size="mini" type="primary" @click="editCompany(scope.row)">编辑</el-button>
                            <el-button size="mini" type="danger" @click="deleteCompany(scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div style="margin-top: 20px; text-align: right;">
                    <el-pagination
                        @size-change="handleCompanySizeChange"
                        @current-change="handleCompanyCurrentChange"
                        :current-page="companyPagination.pageNo"
                        :page-sizes="[10, 20, 50, 100]"
                        :page-size="companyPagination.pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="companyPagination.total">
                    </el-pagination>
                </div>
            </el-tab-pane>
            
            <el-tab-pane label="专家信息管理" name="expert">
                <div style="margin-bottom: 20px;">
                    <el-input
                        v-model="expertSearchKeyword"
                        placeholder="输入专家姓名、编号或研究方向搜索"
                        style="width: 300px;"
                        clearable>
                    </el-input>
                    <el-button type="primary" @click="searchExpert" style="margin-left: 10px;">搜索</el-button>
                    <el-button @click="resetExpertSearch" style="margin-left: 10px;">重置</el-button>
                </div>
                <el-table
                    :data="expertManageList"
                    v-loading="expertLoading"
                    stripe
                    border
                    style="width: 100%">
                    <el-table-column prop="expertCode" label="专家编号" width="120"></el-table-column>
                    <el-table-column prop="name" label="专家姓名" width="120"></el-table-column>
                    <el-table-column prop="college" label="所属学院" width="150"></el-table-column>
                    <el-table-column prop="title" label="职称" width="100"></el-table-column>
                    <el-table-column prop="researchKeywords" label="研究方向" min-width="200" show-overflow-tooltip></el-table-column>
                    <el-table-column label="操作" width="180" align="center">
                        <template #default="scope">
                            <el-button size="mini" type="primary" @click="editExpertInfo(scope.row)">编辑</el-button>
                            <el-button size="mini" type="danger" @click="deleteExpertInfo(scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div style="margin-top: 20px; text-align: right;">
                    <el-pagination
                        @size-change="handleExpertSizeChange"
                        @current-change="handleExpertCurrentChange"
                        :current-page="expertPagination.pageNo"
                        :page-sizes="[10, 20, 50, 100]"
                        :page-size="expertPagination.pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="expertPagination.total">
                    </el-pagination>
                </div>
            </el-tab-pane>
            
            <el-tab-pane label="项目信息管理" name="project">
                <div style="margin-bottom: 20px;">
                    <el-input
                        v-model="projectSearchKeyword"
                        placeholder="输入项目名称、编号或技术关键词搜索"
                        style="width: 300px;"
                        clearable>
                    </el-input>
                    <el-button type="primary" @click="searchProject" style="margin-left: 10px;">搜索</el-button>
                    <el-button @click="resetProjectSearch" style="margin-left: 10px;">重置</el-button>
                </div>
                <el-table
                    :data="projectList"
                    v-loading="projectLoading"
                    stripe
                    border
                    style="width: 100%">
                    <el-table-column prop="projectCode" label="项目编号" width="120"></el-table-column>
                    <el-table-column prop="projectName" label="项目名称" min-width="200"></el-table-column>
                    <el-table-column prop="department" label="所属部门" width="120"></el-table-column>
                    <el-table-column prop="projectType" label="项目类型" width="100"></el-table-column>
                    <el-table-column prop="leaderCode" label="负责人" width="100"></el-table-column>
                    <el-table-column prop="techMaturity" label="技术成熟度" width="120"></el-table-column>
                    <el-table-column label="操作" width="180" align="center">
                        <template #default="scope">
                            <el-button size="mini" type="primary" @click="editProject(scope.row)">编辑</el-button>
                            <el-button size="mini" type="danger" @click="deleteProject(scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div style="margin-top: 20px; text-align: right;">
                    <el-pagination
                        @size-change="handleProjectSizeChange"
                        @current-change="handleProjectCurrentChange"
                        :current-page="projectPagination.pageNo"
                        :page-sizes="[10, 20, 50, 100]"
                        :page-size="projectPagination.pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="projectPagination.total">
                    </el-pagination>
                </div>
            </el-tab-pane>
        </el-tabs>
    </el-dialog>
    
    <!-- 编辑企业对话框 -->
    <el-dialog
        title="编辑企业信息"
        :visible.sync="editCompanyDialogVisible"
        width="50%"
        :close-on-click-modal="false">
        <el-form :model="currentCompany" ref="companyForm" label-width="120px" :rules="companyRules">
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="企业编号" prop="companyCode">
                        <el-input v-model="currentCompany.companyCode" disabled></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="企业名称" prop="companyName">
                        <el-input v-model="currentCompany.companyName"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="企业类型" prop="companyType">
                        <el-input v-model="currentCompany.companyType"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="所属行业" prop="industryPrimary">
                        <el-input v-model="currentCompany.industryPrimary"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="联系人" prop="contactPerson">
                        <el-input v-model="currentCompany.contactPerson"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="联系方式" prop="contactInfo">
                        <el-input v-model="currentCompany.contactInfo"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item label="主营业务关键词" prop="businessKeywords">
                <el-input v-model="currentCompany.businessKeywords" type="textarea" rows="2"></el-input>
            </el-form-item>
            <el-form-item label="备注" prop="remarks">
                <el-input v-model="currentCompany.remarks" type="textarea" rows="3"></el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="editCompanyDialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="saveCompany" :loading="saveLoading">保 存</el-button>
        </span>
    </el-dialog>
    
    <!-- 编辑专家对话框 -->
    <el-dialog
        title="编辑专家信息"
        :visible.sync="editExpertDialogVisible"
        width="50%"
        :close-on-click-modal="false">
        <el-form :model="currentExpert" ref="expertForm" label-width="120px" :rules="expertFormRules">
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="专家编号" prop="expertCode">
                        <el-input v-model="currentExpert.expertCode" disabled></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="专家姓名" prop="name">
                        <el-input v-model="currentExpert.name"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="所属学院" prop="college">
                        <el-input v-model="currentExpert.college"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="职称" prop="title">
                        <el-input v-model="currentExpert.title"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item label="研究方向" prop="researchKeywords">
                <el-input v-model="currentExpert.researchKeywords" type="textarea" rows="2"></el-input>
            </el-form-item>
            <el-form-item label="备注" prop="remarks">
                <el-input v-model="currentExpert.remarks" type="textarea" rows="3"></el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="editExpertDialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="saveExpert" :loading="saveLoading">保 存</el-button>
        </span>
    </el-dialog>
    
    <!-- 编辑项目对话框 -->
    <el-dialog
        title="编辑项目信息"
        :visible.sync="editProjectDialogVisible"
        width="50%"
        :close-on-click-modal="false">
        <el-form :model="currentProject" ref="projectForm" label-width="120px" :rules="projectFormRules">
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="项目编号" prop="projectCode">
                        <el-input v-model="currentProject.projectCode" disabled></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="项目名称" prop="projectName">
                        <el-input v-model="currentProject.projectName"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="所属部门" prop="department">
                        <el-input v-model="currentProject.department"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="项目类型" prop="projectType">
                        <el-input v-model="currentProject.projectType"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="20">
                <el-col :span="12">
                    <el-form-item label="负责人编号" prop="leaderCode">
                        <el-input v-model="currentProject.leaderCode"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="技术成熟度" prop="techMaturity">
                        <el-input v-model="currentProject.techMaturity"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item label="核心技术关键词" prop="coreTechKeywords">
                <el-input v-model="currentProject.coreTechKeywords" type="textarea" rows="2"></el-input>
            </el-form-item>
            <el-form-item label="备注" prop="remarks">
                <el-input v-model="currentProject.remarks" type="textarea" rows="3"></el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="editProjectDialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="saveProject" :loading="saveLoading">保 存</el-button>
        </span>
    </el-dialog>
    
    <!-- 删除确认对话框 -->
    <el-dialog
        title="删除确认"
        :visible.sync="deleteItemDialogVisible"
        width="30%"
        :close-on-click-modal="false">
        <div class="delete-confirm-content">
            <i class="el-icon-warning" style="color: #E6A23C; font-size: 24px; margin-right: 10px;"></i>
            <span>确定要删除该条{{ deleteItemType === 'company' ? '企业' : (deleteItemType === 'expert' ? '专家' : '项目') }}信息吗？</span>
        </div>
        <div class="delete-confirm-detail" style="margin-top: 20px; color: #F56C6C;">
            此操作不可恢复，请谨慎操作！
        </div>
        <span slot="footer" class="dialog-footer">
            <el-button @click="deleteItemDialogVisible = false">取 消</el-button>
            <el-button type="danger" @click="confirmDeleteItem" :loading="deleteItemLoading">确定删除</el-button>
        </span>
    </el-dialog>
</div>

<!-- 引入echarts -->
<script src="${base}/static/plugins/echarts/echarts.min.js"></script>
<script>
    "use strict";
    
    var relationVue = new _Vue({
        el: '#app',
        data: function () {
            return {
                loading: false,
                tableLoading: false,
                expertCode: '',
                expertList: [],
                expertInfo: {},
                expertInfoDetails: {},
                relatedProjects: [],
                selectedProject: {}, // 选中的项目详情
                selectedCompany: {}, // 选中的企业详情
                relatedCompanies: [], // 关联企业列表
                expertDetailsVisible: false,
                projectDetailsVisible: false,
                companyDetailsVisible: false,
                projectDetails: {},
                companyDetails: {},
                // 分页相关
                currentPage: 1,
                pageSize: 10,
                total: 0,
                // 搜索关键词
                searchKeyword: '',
                // 控制空信息显示
                showEmptyInfo: true,
                // 图表实例
                chartInstance: null,
                addDataVisible: false,
                activeDataType: 'expert',
                newExpertForm: {
                    expertCode: '',
                    name: '',
                    gender: '',
                    age: 0,
                    title: '',
                    highestEducation: '',
                    firstLevelDiscipline: '',
                    secondLevelDiscipline: '',
                    college: '',
                    insideOutside: '',
                    ipOwnership: '',
                    socialPositions: '',
                    verticalProjects: '',
                    horizontalProjects: '',
                    researchKeywords: '',
                    contact: '',
                    remarks: ''
                },
                expertRules: {
                    expertCode: [
                        { required: true, message: '请输入专家编号', trigger: 'blur' },
                        { pattern: /^[A-Za-z0-9-]+$/, message: '请输入有效的编号格式', trigger: 'blur' }
                    ],
                    name: [
                        { required: true, message: '请输入专家姓名', trigger: 'blur' }
                    ],
                    gender: [
                        { required: true, message: '请选择性别', trigger: 'change' }
                    ],
                    age: [
                        { required: true, message: '请输入年龄', trigger: 'blur' },
                        { type: 'number', message: '请输入有效的数字', trigger: 'blur' }
                    ],
                    title: [
                        { required: true, message: '请输入职称', trigger: 'blur' }
                    ],
                    highestEducation: [
                        { required: true, message: '请选择最高学历', trigger: 'change' }
                    ],
                    firstLevelDiscipline: [
                        { required: true, message: '请输入一级学科', trigger: 'blur' }
                    ],
                    secondLevelDiscipline: [
                        { required: true, message: '请输入二级学科', trigger: 'blur' }
                    ],
                    college: [
                        { required: true, message: '请输入所属学院', trigger: 'blur' }
                    ],
                    insideOutside: [
                        { required: true, message: '请选择校内/外标识', trigger: 'change' }
                    ],
                    ipOwnership: [
                        { required: true, message: '请输入知识产权持有量', trigger: 'blur' },
                        { type: 'number', message: '请输入有效的数字', trigger: 'blur' }
                    ],
                    socialPositions: [
                        { required: true, message: '请输入社会职务', trigger: 'blur' }
                    ],
                    verticalProjects: [
                        { required: true, message: '请输入纵向项目数', trigger: 'blur' },
                        { type: 'number', message: '请输入有效的数字', trigger: 'blur' }
                    ],
                    horizontalProjects: [
                        { required: true, message: '请输入横向项目数', trigger: 'blur' },
                        { type: 'number', message: '请输入有效的数字', trigger: 'blur' }
                    ],
                    researchKeywords: [
                        { required: true, message: '请输入研究方向关键词', trigger: 'blur' }
                    ],
                    contact: [
                        { required: true, message: '请输入联系方式', trigger: 'blur' }
                    ],
                    remarks: [
                        { required: true, message: '请输入备注', trigger: 'blur' }
                    ]
                },
                newProjectForm: {
                    projectCode: '',
                    projectName: '',
                    department: '',
                    leaderCode: '',
                    participantExperts: '',
                    projectType: '',
                    techMaturity: '',
                    marketStage: '',
                    transformationMode: '',
                    coreTechKeywords: '',
                    applicationIndustry: '',
                    ipDetails: '',
                    budget: '',
                    cooperationTendency: '',
                    contact: '',
                    remarks: ''
                },
                projectRules: {
                    projectCode: [
                        { required: true, message: '请输入项目编号', trigger: 'blur' },
                        { pattern: /^[A-Za-z0-9-]+$/, message: '请输入有效的编号格式', trigger: 'blur' }
                    ],
                    projectName: [
                        { required: true, message: '请输入项目名称', trigger: 'blur' }
                    ],
                    department: [
                        { required: true, message: '请输入所属部门', trigger: 'blur' }
                    ],
                    leaderCode: [
                        { required: true, message: '请输入负责人编号', trigger: 'blur' },
                        { pattern: /^[A-Za-z0-9-]+$/, message: '请输入有效的编号格式', trigger: 'blur' }
                    ],
                    projectType: [
                        { required: true, message: '请输入项目类型', trigger: 'blur' }
                    ],
                    techMaturity: [
                        { required: true, message: '请输入技术成熟度', trigger: 'blur' }
                    ],
                    marketStage: [
                        { required: true, message: '请输入市场化阶段', trigger: 'blur' }
                    ],
                    transformationMode: [
                        { required: true, message: '请输入转化方式', trigger: 'blur' }
                    ],
                    coreTechKeywords: [
                        { required: true, message: '请输入核心技术关键词', trigger: 'blur' }
                    ],
                    applicationIndustry: [
                        { required: true, message: '请输入应用行业', trigger: 'blur' }
                    ],
                    ipDetails: [
                        { required: true, message: '请输入知识产权详情', trigger: 'blur' }
                    ],
                    budget: [
                        { required: true, message: '请输入预算需求', trigger: 'blur' },
                        { type: 'number', message: '请输入有效的数字', trigger: 'blur' }
                    ],
                    cooperationTendency: [
                        { required: true, message: '请输入合作企业意向', trigger: 'blur' }
                    ],
                    contact: [
                        { required: true, message: '请输入联系方式', trigger: 'blur' }
                    ],
                    remarks: [
                        { required: true, message: '请输入备注', trigger: 'blur' }
                    ]
                },
                newCompanyForm: {
                    companyCode: '',
                    companyName: '',
                    companyType: '',
                    industryPrimary: '',
                    industrySecondary: '',
                    registrationAddress: '',
                    contactPerson: '',
                    contactInfo: '',
                    businessKeywords: '',
                    cooperationType: '',
                    requiredTechField: '',
                    requiredExpertTitle: '',
                    cooperationStatus: '',
                    cooperationHistory: '',
                    remarks: ''
                },
                companyRules: {
                    companyCode: [
                        { required: true, message: '请输入企业编号', trigger: 'blur' },
                        { pattern: /^[A-Za-z0-9-]+$/, message: '请输入有效的编号格式', trigger: 'blur' }
                    ],
                    companyName: [
                        { required: true, message: '请输入企业名称', trigger: 'blur' }
                    ],
                    companyType: [
                        { required: true, message: '请输入企业类型', trigger: 'blur' }
                    ],
                    industryPrimary: [
                        { required: true, message: '请输入所属行业(一级)', trigger: 'blur' }
                    ],
                    industrySecondary: [
                        { required: true, message: '请输入所属行业(二级)', trigger: 'blur' }
                    ],
                    registrationAddress: [
                        { required: true, message: '请输入注册地址', trigger: 'blur' }
                    ],
                    contactPerson: [
                        { required: true, message: '请输入联系人', trigger: 'blur' }
                    ],
                    contactInfo: [
                        { required: true, message: '请输入联系方式', trigger: 'blur' }
                    ],
                    businessKeywords: [
                        { required: true, message: '请输入主营业务关键词', trigger: 'blur' }
                    ],
                    cooperationType: [
                        { required: true, message: '请输入合作需求类型', trigger: 'blur' }
                    ],
                    requiredTechField: [
                        { required: true, message: '请输入需求技术领域', trigger: 'blur' }
                    ],
                    requiredExpertTitle: [
                        { required: true, message: '请输入需求专家职称', trigger: 'blur' }
                    ],
                    cooperationStatus: [
                        { required: true, message: '请输入合作状态', trigger: 'blur' }
                    ],
                    cooperationHistory: [
                        { required: true, message: '请输入合作历史项目', trigger: 'blur' }
                    ],
                    remarks: [
                        { required: true, message: '请输入备注', trigger: 'blur' }
                    ]
                },
                submitLoading: false,
                jumpPage: 1,
                // 表格高度自适应
                tableMaxHeight: 500,
                deleteConfirmVisible: false,
                deleteLoading: false,
                expertToDelete: {},
                managementDialogVisible: false,
                activeManagementTab: 'company',
                companySearchKeyword: '',
                companyLoading: false,
                companyList: [],
                companyPagination: {
                    pageNo: 1,
                    pageSize: 10,
                    total: 0
                },
                expertSearchKeyword: '',
                expertLoading: false,
                expertManageList: [],
                expertPagination: {
                    pageNo: 1,
                    pageSize: 10,
                    total: 0
                },
                projectSearchKeyword: '',
                projectLoading: false,
                projectList: [],
                projectPagination: {
                    pageNo: 1,
                    pageSize: 10,
                    total: 0
                },
                deleteItemDialogVisible: false,
                deleteItemType: '',
                deleteItemLoading: false,
                currentCompany: {},
                currentExpert: {},
                currentProject: {},
                editCompanyDialogVisible: false,
                editExpertDialogVisible: false,
                editProjectDialogVisible: false,
                saveLoading: false
            }
        },
        computed: {
            // 计算显示的页码数组
            displayPageNumbers: function() {
                const maxPage = Math.ceil(this.total / this.pageSize);
                if (maxPage <= 1) return [];
                
                // 显示最多5个页码按钮
                const pages = [];
                const visiblePages = 5;
                const halfVisible = Math.floor(visiblePages / 2);
                
                let startPage = Math.max(1, this.currentPage - halfVisible);
                let endPage = Math.min(maxPage, startPage + visiblePages - 1);
                
                // 调整起始页确保显示指定数量的页码
                if (endPage - startPage + 1 < visiblePages) {
                    startPage = Math.max(1, endPage - visiblePages + 1);
                }
                
                for (let i = startPage; i <= endPage; i++) {
                    pages.push(i);
                }
                
                return pages;
            }
        },
        methods: {
            // 计算表格最大高度
            calculateTableHeight: function() {
                // 根据数据行数动态计算表格高度
                const minRows = 5; // 最小显示5行
                const rowHeight = 50; // 每行高度大约50px
                const headerHeight = 50; // 表头高度
                const footerSpace = 20; // 底部额外空间
                
                // 根据当前数据行数计算合适的高度，最小显示5行
                const rowCount = Math.max(minRows, this.expertList.length);
                // 限制最大高度不超过500px
                this.tableMaxHeight = Math.min(500, rowCount * rowHeight + headerHeight + footerSpace);
            },
            
            // 添加resize事件处理
            handleResize: function() {
                this.calculateTableHeight();
            },
            
            // 获取专家列表（分页）
            getExperts: function() {
                var that = this;
                that.tableLoading = true;
                
                // 使用正确的参数格式
                var url = ms.manager + "/expertmanage/expert/list";

                var params = new URLSearchParams();
                params.append('pageNum', that.currentPage);
                params.append('pageSize', that.pageSize);

                if (that.searchKeyword) {
                    params.append('keyword', that.searchKeyword);
                }

                ms.http.get(url + "?" + params.toString()).then(function (res) {
                    that.tableLoading = false;

                    if (res.result && res.data) {
                        // 正确使用records字段读取数据
                        that.expertList = res.data.records || [];
                        that.total = parseInt(res.data.total) || 0;
                        that.pageSize = parseInt(res.data.size) || 10;
                        that.currentPage = parseInt(res.data.current) || 1;

                        // 如果有专家数据且没有指定查询的专家，默认查询第一个专家
                        if (that.expertList.length > 0 && !that.expertCode) {
                            that.expertCode = that.expertList[0].expertCode;
                            that.queryRelations();
                        }
                        
                        // 如果没有数据，显示提示
                        if (that.expertList.length === 0) {
                            that.$message.info('暂无专家数据');
                        }
                    } else {
                        console.error("API返回错误:", res.msg);
                        that.$notify.error({
                            title: '错误',
                            message: res.msg || '获取专家列表失败'
                        });
                    }
                    
                    // 根据数据计算表格高度
                    that.calculateTableHeight();
                }).catch(function(err) {
                    that.tableLoading = false;
                    console.error("API请求异常:", err);
                    that.$notify.error({
                        title: '错误',
                        message: '获取专家列表失败：' + err
                    });
                });
            },
            
            // 处理页码变化
            handleCurrentChange: function(val) {
                // 确保页码是数值型且在有效范围内
                val = parseInt(val) || 1;
                var maxPage = Math.max(1, Math.ceil(this.total/this.pageSize));
                
                // 确保页码不超出范围
                if (val < 1) {
                    val = 1;
                } else if (val > maxPage) {
                    val = maxPage;
                }
                
                this.currentPage = val;
                this.jumpPage = val; // 同步更新跳转页码
                this.getExperts();
            },
            
            // 处理每页数量变化
            handleSizeChange: function(size) {
                this.pageSize = parseInt(size);
                this.currentPage = 1;
                this.getExperts();
            },
            
            // 编辑专家
            editExpert: function(row) {
                // 跳转到专家编辑页面
                location.href = ms.manager + "/expertmanage/expert/form?expertCode=" + row.expertCode;
            },
            
            // 综合编辑专家和关联数据
            editRelations: function(row) {
                // 跳转到专家综合编辑页面
                location.href = ms.manager + "/expertmanage/relation/edit?expertCode=" + row.expertCode;
            },
            
            // 处理查询关联
            handleQueryRelations: function(expertCode) {
                this.expertCode = expertCode;
                this.queryRelations();
            },
            
            // 查询关联信息
            queryRelations: function() {
                if (!this.expertCode) {
                    this.$message.warning('请先选择专家编号');
                    return;
                }
                
                var that = this;
                that.loading = true;
                console.log("查询专家关联信息: ", that.expertCode);
                
                // 第一步：获取专家基本信息
                ms.http.get(ms.manager + "/expertmanage/expert/get", {
                    expertCode: that.expertCode
                }).then(function(expertRes) {
                    console.log("专家信息获取结果: ", expertRes);
                    
                    if (expertRes.result) {
                        // 设置专家信息
                        that.expertInfo = expertRes.data;
                        that.expertInfoDetails = JSON.parse(JSON.stringify(expertRes.data));
                        
                        // 第二步：获取专家相关的项目信息（项目负责人为该专家）
                        ms.http.get(ms.manager + "/expertmanage/project/getByLeader", {
                            leaderCode: that.expertCode
                        }).then(function(projectsRes) {
                            console.log("项目信息获取结果: ", projectsRes);
                            // 设置关联项目
                            that.relatedProjects = projectsRes.result ? (projectsRes.data || []) : [];
                            
                            // 为项目添加角色标识
                            that.relatedProjects.forEach(function(project) {
                                // 设置专家在项目中的角色
                                if (project.leaderCode === that.expertCode) {
                                    project.relatedRole = "负责人";
                                } else if (project.participantExperts && project.participantExperts.includes(that.expertCode)) {
                                    project.relatedRole = "参与者";
                                } else {
                                    project.relatedRole = "其他";
                            }
                        });
                        
                        // 如果有项目，默认选中第一个
                        if (that.relatedProjects.length > 0) {
                            that.selectedProject = that.relatedProjects[0];
                        } else {
                            that.selectedProject = {};
                        }
                            
                            // 第三步：获取与专家相关的企业信息（企业matched_expert_codes或remarks字段包含专家编号）
                            ms.http.get(ms.manager + "/expertmanage/company/getByExpert", {
                                expertCode: that.expertCode
                            }).then(function(companiesRes) {
                                console.log("企业信息获取结果: ", companiesRes);
                                that.loading = false;
                                
                                if (companiesRes.result) {
                                    // 设置关联企业
                                    that.relatedCompanies = companiesRes.data || [];
                        
                        // 如果有企业，默认选中第一个
                        if (that.relatedCompanies.length > 0) {
                            that.selectedCompany = that.relatedCompanies[0];
                        } else {
                            that.selectedCompany = {};
                        }
                        
                                    // 完成所有查询后，初始化关系图谱
                        that.$nextTick(function() {
                            that.getRelationChartData();
                        });
                    } else {
                                    console.error("获取企业信息失败: ", companiesRes.msg);
                                    that.$message.error("获取企业信息失败: " + companiesRes.msg);
                                }
                            }).catch(function(err) {
                        that.loading = false;
                                console.error("获取企业信息失败: ", err);
                                that.$message.error("获取企业信息失败: " + err);
                            });
                        }).catch(function(err) {
                            that.loading = false;
                            console.error("获取项目信息失败: ", err);
                            that.$message.error("获取项目信息失败: " + err);
                        });
                    } else {
                        that.loading = false;
                        console.error("获取专家信息失败: ", expertRes.msg);
                        that.$message.error("获取专家信息失败: " + expertRes.msg);
                    }
                }).catch(function(err) {
                    that.loading = false;
                    console.error("获取专家信息失败: ", err);
                    that.$message.error("获取专家信息失败: " + err);
                });
            },
            // 获取关系图谱数据
            getRelationChartData: function() {
                var that = this;
                console.log("开始构建关系图谱数据");
                
                // 如果没有专家数据，无法构建图谱
                if (!that.expertInfo.expertCode) {
                    console.log("无专家数据，不构建图谱");
                    return;
                }
                
                // 基于当前已获取的数据构建图谱
                var nodes = [];
                var links = [];
                var categories = [
                    { name: '专家', itemStyle: {color: '#5470c6'} },
                    { name: '项目', itemStyle: {color: '#91cc75'} },
                    { name: '企业', itemStyle: {color: '#fac858'} },
                    { name: '合作专家', itemStyle: {color: '#ee6666'} },
                    { name: '技术领域', itemStyle: {color: '#73c0de'} },
                    { name: '学科', itemStyle: {color: '#3ba272'} },
                    { name: '学院', itemStyle: {color: '#fc8452'} },
                    { name: '行业', itemStyle: {color: '#9a60b4'} }
                ];
                
                // 添加当前专家节点
                var expertNode = {
                    id: 'expert-' + that.expertInfo.expertCode,
                    name: that.expertInfo.name + '\n(' + that.expertInfo.title + ')',
                    value: that.expertInfo.expertCode,
                    category: 0,
                    symbolSize: 70,
                    itemStyle: {
                        color: '#5470c6',
                        borderWidth: 4,
                        borderColor: 'rgba(255, 255, 255, 0.8)',
                        shadowBlur: 10,
                        shadowColor: 'rgba(0, 0, 0, 0.3)'
                    }
                };
                nodes.push(expertNode);
                
                // 创建学科节点（一级和二级学科）
                if (that.expertInfo.firstLevelDiscipline) {
                    var disciplineNode = {
                        id: 'discipline-' + that.expertInfo.firstLevelDiscipline,
                        name: that.expertInfo.firstLevelDiscipline,
                        value: that.expertInfo.firstLevelDiscipline,
                        category: 5,
                        symbolSize: 45,
                        itemStyle: {
                            color: '#3ba272',
                            borderWidth: 2,
                            borderColor: 'rgba(255, 255, 255, 0.8)'
                        }
                    };
                    nodes.push(disciplineNode);
                    
                    // 连接专家和一级学科
                    links.push({
                        source: expertNode.id,
                        target: disciplineNode.id,
                        value: '一级学科',
                        lineStyle: {
                            width: 3,
                            color: '#3ba272',
                            curveness: 0.2
                        }
                    });
                    
                    // 如果有二级学科，则也添加，并与一级学科连接
                    if (that.expertInfo.secondLevelDiscipline) {
                        var secondDisciplineNode = {
                            id: 'discipline-' + that.expertInfo.secondLevelDiscipline,
                            name: that.expertInfo.secondLevelDiscipline,
                            value: that.expertInfo.secondLevelDiscipline,
                            category: 5,
                            symbolSize: 35,
                            itemStyle: {
                                color: '#3ba272',
                                borderWidth: 2,
                                borderColor: 'rgba(255, 255, 255, 0.8)'
                            }
                        };
                        nodes.push(secondDisciplineNode);
                        
                        // 连接专家和二级学科
                        links.push({
                            source: expertNode.id,
                            target: secondDisciplineNode.id,
                            value: '二级学科',
                            lineStyle: {
                                width: 2,
                                color: '#3ba272',
                                curveness: 0.2
                            }
                        });
                        
                        // 一级学科与二级学科连接
                        links.push({
                            source: disciplineNode.id,
                            target: secondDisciplineNode.id,
                            value: '学科分类',
                            lineStyle: {
                                width: 2,
                                type: 'dashed',
                                color: '#3ba272',
                                curveness: 0.2
                            }
                        });
                    }
                }
                
                // 添加所属学院节点
                if (that.expertInfo.college) {
                    var collegeNode = {
                        id: 'college-' + that.expertInfo.college,
                        name: that.expertInfo.college,
                        value: that.expertInfo.college,
                        category: 6,
                        symbolSize: 40,
                        itemStyle: {
                            color: '#fc8452',
                            borderWidth: 2,
                            borderColor: 'rgba(255, 255, 255, 0.8)'
                        }
                    };
                    nodes.push(collegeNode);
                    
                    // 连接专家和学院
                    links.push({
                        source: expertNode.id,
                        target: collegeNode.id,
                        value: '所属学院',
                        lineStyle: {
                            width: 3,
                            color: '#fc8452',
                            curveness: 0.2
                        }
                    });
                }
                
                // 从研究方向关键词创建技术领域节点
                if (that.expertInfo.researchKeywords) {
                    var keywords = that.expertInfo.researchKeywords.split(/[,，;；、]/);
                    keywords.forEach(function(keyword, idx) {
                        keyword = keyword.trim();
                        if (keyword) {
                            var techNode = {
                                id: 'tech-' + keyword,
                                name: keyword,
                                value: keyword,
                                category: 4,
                                symbolSize: 40,
                                itemStyle: {
                                    color: '#73c0de',
                                    borderWidth: 2,
                                    borderColor: 'rgba(255, 255, 255, 0.8)'
                                }
                            };
                            nodes.push(techNode);
                            
                            // 连接专家和技术领域，使用不同曲率避免重叠
                            links.push({
                                source: expertNode.id,
                                target: techNode.id,
                                value: '研究方向',
                                lineStyle: {
                                    width: 2.5,
                                    color: '#73c0de',
                                    curveness: 0.1 + (idx * 0.05)
                                }
                            });
                        }
                    });
                }
                
                // 添加项目节点和连接
                that.relatedProjects.forEach(function(project, idx) {
                    var projectNode = {
                        id: 'project-' + project.projectCode,
                        name: project.projectName,
                        value: project.projectCode,
                        category: 1,
                        symbolSize: 55,
                        symbol: 'rect',
                        itemStyle: {
                            color: '#91cc75',
                            borderWidth: 2,
                            borderColor: 'rgba(255, 255, 255, 0.8)',
                            shadowBlur: 5,
                            shadowColor: 'rgba(0, 0, 0, 0.2)'
                        }
                    };
                    nodes.push(projectNode);
                    
                    // 连接专家和项目
                    var relationText = project.relatedRole || '关联';
                    links.push({
                        source: expertNode.id,
                        target: projectNode.id,
                        value: relationText,
                        lineStyle: {
                            width: relationText === '负责人' ? 4 : 2.5,
                            color: relationText === '负责人' ? '#ff7e67' : '#78c2ad',
                            type: relationText === '参与者' ? 'dashed' : 'solid',
                            curveness: 0.2 + (idx * 0.03)
                        }
                    });
                    
                    // 添加项目参与专家节点
                    if (project.participantExperts && project.participantExperts !== that.expertCode) {
                        var participants = project.participantExperts.split(/[,，;；]/);
                        participants.forEach(function(participant, pidx) {
                            participant = participant.trim();
                            if (participant && participant !== that.expertCode) {
                                var participantNode = {
                                    id: 'expert-' + participant,
                                    name: participant,
                                    value: participant,
                                    category: 3,
                                    symbolSize: 40,
                                    itemStyle: {
                                        color: '#ee6666',
                                        borderWidth: 2,
                                        borderColor: 'rgba(255, 255, 255, 0.8)'
                                    }
                                };
                                
                                // 检查节点是否已存在
                                var existingNode = nodes.find(function(n) { return n.id === participantNode.id; });
                                if (!existingNode) {
                                    nodes.push(participantNode);
                                }
                                
                                // 连接项目和参与专家
                                links.push({
                                    source: projectNode.id,
                                    target: participantNode.id,
                                    value: '参与',
                                    lineStyle: {
                                        width: 2,
                                        type: 'dashed',
                                        color: '#ee6666',
                                        curveness: 0.1 + (pidx * 0.04)
                                    }
                                });
                                
                                // 连接主专家和参与专家（同事关系）
                                links.push({
                                    source: expertNode.id,
                                    target: participantNode.id,
                                    value: '合作同事',
                                    lineStyle: {
                                        width: 1.5,
                                        type: 'dotted',
                                        color: '#909399',
                                        curveness: 0.3 + (pidx * 0.05)
                                    }
                                });
                            }
                        });
                    }
                    
                    // 从项目核心技术关键词添加技术节点
                    if (project.coreTechKeywords) {
                        var techKeywords = project.coreTechKeywords.split(/[,，;；、]/);
                        techKeywords.forEach(function(keyword, tkidx) {
                            keyword = keyword.trim();
                            if (keyword) {
                                var techId = 'tech-' + keyword;
                                
                                // 检查节点是否已存在
                                var existingNode = nodes.find(function(n) { return n.id === techId; });
                                if (!existingNode) {
                                    var techNode = {
                                        id: techId,
                                        name: keyword,
                                        value: keyword,
                                        category: 4,
                                        symbolSize: 35,
                                        itemStyle: {
                                            color: '#73c0de',
                                            borderWidth: 2,
                                            borderColor: 'rgba(255, 255, 255, 0.8)'
                                        }
                                    };
                                    nodes.push(techNode);
                                }
                                
                                // 连接项目和技术
                                links.push({
                                    source: projectNode.id,
                                    target: techId,
                                    value: '核心技术',
                                    lineStyle: {
                                        width: 2,
                                        type: 'dotted',
                                        color: '#73c0de',
                                        curveness: 0.15 + (tkidx * 0.03)
                                    }
                                });
                            }
                        });
                    }
                    
                    // 添加项目所属部门节点
                    if (project.department && project.department !== "未知") {
                        var deptId = 'dept-' + project.department;
                        
                        // 检查节点是否已存在
                        var existingDeptNode = nodes.find(function(n) { return n.id === deptId; });
                        if (!existingDeptNode) {
                            var deptNode = {
                                id: deptId,
                                name: project.department,
                                value: project.department,
                                category: 6,
                                symbolSize: 35,
                                itemStyle: {
                                    color: '#fc8452',
                                    borderWidth: 2,
                                    borderColor: 'rgba(255, 255, 255, 0.8)'
                                }
                            };
                            nodes.push(deptNode);
                        }
                        
                        // 连接项目和部门
                        links.push({
                            source: projectNode.id,
                            target: deptId,
                            value: '所属部门',
                            lineStyle: {
                                width: 1.5,
                                color: '#fc8452',
                                curveness: 0.1
                            }
                        });
                    }
                });
                
                // 添加企业节点和连接
                that.relatedCompanies.forEach(function(company, cidx) {
                    var companyNode = {
                        id: 'company-' + company.companyCode,
                        name: company.companyName,
                        value: company.companyCode,
                        category: 2,
                        symbolSize: 50,
                        symbol: 'roundRect',
                        itemStyle: {
                            color: '#fac858',
                            borderWidth: 2,
                            borderColor: 'rgba(255, 255, 255, 0.8)',
                            shadowBlur: 5,
                            shadowColor: 'rgba(0, 0, 0, 0.2)'
                        }
                    };
                    nodes.push(companyNode);
                    
                    // 连接专家和企业
                    var relationText = (company.cooperationStatus || '关联');
                    links.push({
                        source: expertNode.id,
                        target: companyNode.id,
                        value: relationText,
                        lineStyle: {
                            width: 3,
                            color: '#fac858',
                            type: company.cooperationStatus === '已合作' ? 'solid' : 'dashed',
                            curveness: 0.2 + (cidx * 0.03)
                        }
                    });
                    
                    // 从企业业务关键词添加技术节点
                    if (company.businessKeywords) {
                        var businessKeywords = company.businessKeywords.split(/[,，;；、]/);
                        businessKeywords.forEach(function(keyword, bkidx) {
                            keyword = keyword.trim();
                            if (keyword) {
                                var techId = 'tech-' + keyword;
                                
                                // 检查节点是否已存在
                                var existingNode = nodes.find(function(n) { return n.id === techId; });
                                if (!existingNode) {
                                    var techNode = {
                                        id: techId,
                                        name: keyword,
                                        value: keyword,
                                        category: 4,
                                        symbolSize: 30,
                                        itemStyle: {
                                            color: '#73c0de',
                                            borderWidth: 2,
                                            borderColor: 'rgba(255, 255, 255, 0.8)'
                                        }
                                    };
                                    nodes.push(techNode);
                                }
                                
                                // 连接企业和技术
                                links.push({
                                    source: companyNode.id,
                                    target: techId,
                                    value: '业务领域',
                                    lineStyle: {
                                        width: 1.5,
                                        type: 'dotted',
                                        color: '#73c0de',
                                        curveness: 0.1 + (bkidx * 0.03)
                                    }
                                });
                            }
                        });
                    }
                    
                    // 添加企业行业节点
                    if (company.industryPrimary && company.industryPrimary !== "未知") {
                        var industryId = 'industry-' + company.industryPrimary;
                        
                        // 检查节点是否已存在
                        var existingIndustryNode = nodes.find(function(n) { return n.id === industryId; });
                        if (!existingIndustryNode) {
                            var industryNode = {
                                id: industryId,
                                name: company.industryPrimary,
                                value: company.industryPrimary,
                                category: 7,
                                symbolSize: 35,
                                itemStyle: {
                                    color: '#9a60b4',
                                    borderWidth: 2,
                                    borderColor: 'rgba(255, 255, 255, 0.8)'
                                }
                            };
                            nodes.push(industryNode);
                        }
                        
                        // 连接企业和行业
                        links.push({
                            source: companyNode.id,
                            target: industryId,
                            value: '所属行业',
                            lineStyle: {
                                width: 1.5,
                                color: '#9a60b4',
                                curveness: 0.15
                            }
                        });
                    }
                    
                    // 查找企业是否与项目相关联
                    if (company.cooperationHistory) {
                        var projectCodes = company.cooperationHistory.split(/[,，;；、]/).map(function(code) {
                            return code.trim();
                        });
                        
                        that.relatedProjects.forEach(function(project, pidx) {
                            if (projectCodes.includes(project.projectCode)) {
                                links.push({
                                    source: companyNode.id,
                                    target: 'project-' + project.projectCode,
                                    value: '合作项目',
                                    lineStyle: {
                                        width: 2.5,
                                        color: '#f3a530',
                                        type: 'solid',
                                        curveness: 0.25 + (pidx * 0.03)
                                    }
                                });
                            }
                        });
                    }
                });
                
                console.log("图谱数据构建完成: ", {nodes: nodes, links: links, categories: categories});
                
                // 使用构建的数据初始化图谱
                that.initRelationChartWithData({
                    nodes: nodes,
                    links: links,
                    categories: categories
                });
            },
            
            // 放大图表
            zoomIn: function() {
                if (this.chartInstance) {
                    this.chartInstance.dispatchAction({
                        type: 'dataZoom',
                        start: 0,
                        end: 100,
                        zoomScale: 1.2
                    });
                }
            },
            
            // 缩小图表
            zoomOut: function() {
                if (this.chartInstance) {
                    this.chartInstance.dispatchAction({
                        type: 'dataZoom',
                        start: 0,
                        end: 100,
                        zoomScale: 0.8
                    });
                }
            },
            
            // 重置图表
            resetChart: function() {
                if (this.chartInstance) {
                    this.getRelationChartData();
                }
            },
            
            // 使用后端提供的图谱数据初始化图谱
            initRelationChartWithData: function(chartData) {
                var chartDom = document.getElementById('relationChart');
                if (!chartDom) {
                    console.error("找不到图表DOM元素");
                    return;
                }
                
                // 确保echarts库正确加载
                if (typeof echarts === 'undefined') {
                    console.error("ECharts库未加载");
                    this.$notify.error({
                        title: '图表加载失败',
                        message: 'ECharts库未正确加载，请刷新页面重试',
                        duration: 3000
                    });
                    return;
                }
                
                try {
                    var myChart = echarts.init(chartDom, null, {
                        renderer: 'canvas'
                    });
                myChart.clear();
                
                // 保存图表实例
                this.chartInstance = myChart;
                
                // 创建节点ID到实体数据的映射,用于点击事件
                var that = this;
                var nodeIdToEntityMap = {};
                
                    // 设置图表选项
                var option = {
                    title: {
                            text: that.expertInfo.name + ' 专家关系图谱',
                            subtext: '专家编号: ' + that.expertInfo.expertCode,
                        left: 'center',
                        top: 10,
                        textStyle: {
                                fontSize: 20,
                                fontWeight: 'bold',
                                color: '#303133'
                            },
                            subtextStyle: {
                                fontSize: 14,
                                color: '#606266'
                        }
                    },
                    tooltip: {
                        trigger: 'item',
                            backgroundColor: 'rgba(255, 255, 255, 0.95)',
                            borderColor: '#eee',
                        borderWidth: 1,
                            borderRadius: 4,
                            padding: 15,
                        textStyle: {
                            color: '#333'
                        },
                        formatter: function(params) {
                            if (params.dataType === 'node') {
                                    var entityType = params.data.id.split('-')[0];
                                    var entityCode = params.data.id.split('-')[1];
                                    
                                    var html = '<div class="tooltip-title">' + params.name + '</div>';
                                    html += '<div class="tooltip-content">';
                                    
                                    // 节点类型
                                    var typeText = '';
                                    if (entityType === 'expert') typeText = '专家';
                                    else if (entityType === 'project') typeText = '项目';
                                    else if (entityType === 'company') typeText = '企业';
                                    else if (entityType === 'tech') typeText = '技术领域';
                                    else if (entityType === 'discipline') typeText = '学科领域';
                                    else if (entityType === 'college') typeText = '学院';
                                    else if (entityType === 'industry') typeText = '行业';
                                    
                                    html += '<div class="tooltip-row"><span class="tooltip-label">类型：</span><span class="tooltip-value">' + typeText + '</span></div>';
                                    
                                    if (entityCode) {
                                        html += '<div class="tooltip-row"><span class="tooltip-label">编号：</span><span class="tooltip-value">' + entityCode + '</span></div>';
                                    }
                                    
                                    // 添加属性信息
                                if (params.data.attributes) {
                                    for (var key in params.data.attributes) {
                                            html += '<div class="tooltip-row"><span class="tooltip-label">' + key + '：</span><span class="tooltip-value">' + 
                                            params.data.attributes[key] + '</span></div>';
                                    }
                                }
                                
                                    // 为不同类型节点添加特定信息
                                    if (entityType === 'expert') {
                                        // 专家信息
                                        if (that.expertInfo.expertCode === entityCode) {
                                            html += '<div class="tooltip-row"><span class="tooltip-label">职称：</span><span class="tooltip-value">' + 
                                                  (that.expertInfo.title || '未知') + '</span></div>';
                                            html += '<div class="tooltip-row"><span class="tooltip-label">学院：</span><span class="tooltip-value">' + 
                                                  (that.expertInfo.college || '未知') + '</span></div>';
                                            html += '<div class="tooltip-row"><span class="tooltip-label">研究方向：</span><span class="tooltip-value">' + 
                                                  (that.expertInfo.researchKeywords || '未知') + '</span></div>';
                                        }
                                    } else if (entityType === 'project') {
                                        // 项目信息
                                        var project = that.relatedProjects.find(function(p) { return p.projectCode === entityCode; });
                                        if (project) {
                                            html += '<div class="tooltip-row"><span class="tooltip-label">部门：</span><span class="tooltip-value">' + 
                                                  (project.department || '未知') + '</span></div>';
                                            html += '<div class="tooltip-row"><span class="tooltip-label">类型：</span><span class="tooltip-value">' + 
                                                  (project.projectType || '未知') + '</span></div>';
                                            html += '<div class="tooltip-row"><span class="tooltip-label">关键技术：</span><span class="tooltip-value">' + 
                                                  (project.coreTechKeywords || '未知') + '</span></div>';
                                        }
                                    } else if (entityType === 'company') {
                                        // 企业信息
                                        var company = that.relatedCompanies.find(function(c) { return c.companyCode === entityCode; });
                                        if (company) {
                                            html += '<div class="tooltip-row"><span class="tooltip-label">企业类型：</span><span class="tooltip-value">' + 
                                                  (company.companyType || '未知') + '</span></div>';
                                            html += '<div class="tooltip-row"><span class="tooltip-label">行业：</span><span class="tooltip-value">' + 
                                                  (company.industryPrimary ? company.industryPrimary + '/' + company.industrySecondary : '未知') + '</span></div>';
                                            html += '<div class="tooltip-row"><span class="tooltip-label">合作状态：</span><span class="tooltip-value">' + 
                                                  (company.cooperationStatus || '未知') + '</span></div>';
                                        }
                                    } else if (entityType === 'tech') {
                                        // 技术领域节点 - 查找相关项目和企业
                                        var relatedProjectCount = 0;
                                        var relatedCompanyCount = 0;
                                        
                                        that.relatedProjects.forEach(function(p) {
                                            if (p.coreTechKeywords && p.coreTechKeywords.includes(params.name)) {
                                                relatedProjectCount++;
                                            }
                                        });
                                        
                                        that.relatedCompanies.forEach(function(c) {
                                            if (c.businessKeywords && c.businessKeywords.includes(params.name)) {
                                                relatedCompanyCount++;
                                            }
                                        });
                                        
                                        html += '<div class="tooltip-row"><span class="tooltip-label">相关项目：</span><span class="tooltip-value">' + 
                                              relatedProjectCount + ' 个</span></div>';
                                        html += '<div class="tooltip-row"><span class="tooltip-label">相关企业：</span><span class="tooltip-value">' + 
                                              relatedCompanyCount + ' 个</span></div>';
                                    }
                                    
                                    html += '</div>';
                                    
                                    return html;
                                } else if (params.dataType === 'edge') {
                                    // 边的提示信息
                                    var html = '<div class="tooltip-title">' + params.value + ' 关系</div>' +
                                           '<div class="tooltip-content">';
                                    
                                    // 提取源节点和目标节点的名称
                                    var sourceId = params.data.source;
                                    var targetId = params.data.target;
                                    var sourceName = '';
                                    var targetName = '';
                                    
                                    // 查找源节点和目标节点
                                    chartData.nodes.forEach(function(node) {
                                        if (node.id === sourceId) sourceName = node.name;
                                        if (node.id === targetId) targetName = node.name;
                                    });
                                    
                                    html += '<div class="tooltip-row"><span class="tooltip-label">从：</span><span class="tooltip-value">' + 
                                          sourceName + '</span></div>';
                                    html += '<div class="tooltip-row"><span class="tooltip-label">到：</span><span class="tooltip-value">' + 
                                          targetName + '</span></div>';
                                    html += '</div>';
                                    
                                    return html;
                                }
                            },
                            extraCssText: 'box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);'
                        },
                        legend: {
                            data: chartData.categories.map(function(category) {
                                return {
                                    name: category.name,
                                    icon: category.name === '专家' ? 'circle' : 
                                           category.name === '项目' ? 'rect' : 
                                           category.name === '企业' ? 'roundRect' : 'circle'
                                }
                            }),
                            orient: 'horizontal',
                            bottom: 10,
                            left: 'center',
                            textStyle: {
                                color: '#606266'
                            },
                            itemGap: 15,
                            itemWidth: 15,
                            itemHeight: 10,
                            pageIconSize: 12,
                            selector: [
                                {
                                    type: 'all',
                                    title: '全选',
                                    icon: 'path://M0,0 L12,0 L12,12 L0,12 Z M1,1 L11,1 L11,11 L1,11 Z M3,6 L9,6 M6,3 L6,9'
                                },
                                {
                                    type: 'inverse',
                                    title: '反选',
                                    icon: 'path://M0,0 L12,0 L12,12 L0,12 Z M1,1 L11,1 L11,11 L1,11 Z M3,3 L9,9 M3,9 L9,3'
                                }
                            ],
                            selectorLabel: {
                                color: '#606266',
                                backgroundColor: '#ffffff',
                                borderWidth: 1,
                                borderColor: '#dcdfe6',
                                borderRadius: 4,
                                padding: [3, 8]
                            },
                            emphasis: {
                                selectorLabel: {
                                    backgroundColor: '#409EFF',
                                    color: '#ffffff'
                                }
                            },
                            selectorItemGap: 10,
                            selectorPosition: 'end',
                            selected: {
                                itemStyle: {
                                    color: '#a0cfff',
                                    shadowBlur: 0,
                                    shadowColor: 'rgba(0, 0, 0, 0)'
                                },
                                textStyle: {
                                    color: '#303133'
                                }
                            },
                            unselected: {
                                itemStyle: {
                                    opacity: 0.3
                                },
                                textStyle: {
                                    opacity: 0.6
                                }
                            }
                        },
                    animationDuration: 1500,
                    animationEasingUpdate: 'quinticInOut',
                    series: [
                        {
                                name: '专家关系',
                            type: 'graph',
                            layout: 'force',
                                force: {
                                    repulsion: 400,
                                    gravity: 0.1,
                                    edgeLength: [80, 180],
                                    friction: 0.2,
                                    layoutAnimation: true
                                },
                            roam: true,
                                draggable: true,
                                zoom: 0.9,
                                nodeScaleRatio: 0.6,
                            label: {
                                show: true,
                                position: 'right',
                                    formatter: '{b}',
                                    distance: 5,
                                fontSize: 12,
                                    color: '#303133',
                                    fontWeight: 500,
                                    backgroundColor: 'rgba(255, 255, 255, 0.7)',
                                    padding: [3, 5],
                                    borderRadius: 3
                            },
                            edgeLabel: {
                                show: false,
                                formatter: '{c}',
                                    fontSize: 10,
                                    color: '#606266'
                                },
                                data: chartData.nodes,
                                links: chartData.links,
                                categories: chartData.categories,
                            emphasis: {
                                focus: 'adjacency',
                                lineStyle: {
                                        width: 5
                                },
                                label: {
                                    show: true,
                                        fontSize: 12,
                                        fontWeight: 'bold'
                                },
                                edgeLabel: {
                                    show: true,
                                    fontSize: 12,
                                        formatter: '{c}'
                                }
                            }
                        }
                    ]
                };
                
                    // 设置图表选项
                myChart.setOption(option);
                
                // 监听DOM变化，找到图例选择器按钮并修改其样式
                var buttonStyleInterval = setInterval(function() {
                    var legendButtons = document.querySelectorAll('button');
                    var found = false;
                    
                    for (var i = 0; i < legendButtons.length; i++) {
                        var btn = legendButtons[i];
                        if (btn.textContent === '全选' || btn.textContent === '反选') {
                            found = true;
                            
                            // 设置按钮背景色为蓝色
                            if (btn.style.backgroundColor != 'rgb(64, 158, 255)') {
                                btn.style.backgroundColor = '#409EFF';
                                btn.style.color = '#ffffff';
                                btn.style.border = '1px solid #409EFF';
                                btn.style.borderRadius = '4px';
                                btn.style.padding = '4px 8px';
                                btn.style.margin = '0 4px';
                            }
                        }
                    }
                    
                    // 如果找到按钮并设置了样式，停止定时器
                    if (found) {
                        clearInterval(buttonStyleInterval);
                    }
                }, 100);
                
                // 设置最大超时时间
                setTimeout(function() {
                    clearInterval(buttonStyleInterval);
                }, 3000);
                
                // 监听窗口大小变化，重新调整图表大小
                window.addEventListener('resize', function() {
                    myChart.resize();
                });
                } catch (error) {
                    console.error("初始化图表时发生错误:", error);
                    that.$notify.error({
                        title: '图表加载失败',
                        message: '初始化图表时发生错误，请刷新页面重试',
                        duration: 3000
                    });
                }
            },
            
            // 查看专家详情
            showExpertDetails: function(expert) {
                this.expertInfoDetails = expert;
                this.expertDetailsVisible = true;
            },
            // 查看项目详情
            showProjectDetails: function(project) {
                this.projectDetails = project;
                this.projectDetailsVisible = true;
            },
            // 查看企业详情
            viewCompanyDetails: function(company) {
                if (!company) {
                    this.$message.warning('没有关联企业信息');
                    return;
                }
                this.companyDetails = company;
                this.companyDetailsVisible = true;
            },
            // 旧的图谱初始化方法 - 保持为兼容性考虑但不再使用
            initRelationChart: function() {
                this.getRelationChartData();
            },
            // 点击项目行，显示详细信息
            handleProjectRowClick: function(row) {
                this.selectedProject = row;
            },
            // 点击企业行，显示详细信息
            handleCompanyRowClick: function(row) {
                this.selectedCompany = row;
            },
            // 跳转到数据导入页面
            handleDataImport: function() {
                location.href = ms.manager + "/expertmanage/relation/import";
            },
            showAddDataDialog: function() {
                // Navigate to the expert edit page
                location.href = ms.manager + "/expertmanage/expert/form";
            },
            closeAddDataDialog: function() {
                this.addDataVisible = false;
            },
            submitAddData: function() {
                this.submitLoading = true;
                // 表单验证逻辑
                this.$refs[this.activeDataType + 'Form'].validate((valid) => {
                    if (valid) {
                        // 表单数据提交逻辑
                        // 这里需要根据activeDataType选择不同的表单提交
                        if (this.activeDataType === 'expert') {
                            // 提交专家数据
                            this.submitExpertData();
                        } else if (this.activeDataType === 'project') {
                            // 提交项目数据
                            this.submitProjectData();
                        } else if (this.activeDataType === 'company') {
                            // 提交企业数据
                            this.submitCompanyData();
                        }
                    } else {
                        this.submitLoading = false;
                    }
                });
            },
            submitExpertData: function() {
                // 实现提交专家数据的逻辑
                var that = this;
                var url = ms.manager + "/expertmanage/relation/addExpert";
                
                ms.http.post(url, JSON.stringify(that.newExpertForm), {
                    headers: {
                        'Content-Type': 'application/json'
                    }
                }).then(function (res) {
                    that.submitLoading = false;
                    if (res.result) {
                        that.$notify.success({
                            title: '成功',
                            message: '专家信息添加成功'
                        });
                        that.closeAddDataDialog();
                        // 重新加载专家列表
                        that.getExperts();
                    } else {
                        that.$notify.error({
                            title: '错误',
                            message: res.msg || '添加失败'
                        });
                    }
                }).catch(function(err) {
                    that.submitLoading = false;
                    that.$notify.error({
                        title: '错误',
                        message: '添加失败：' + err
                    });
                });
            },
            submitProjectData: function() {
                // 实现提交项目数据的逻辑
                var that = this;
                var url = ms.manager + "/expertmanage/relation/addProject";
                
                ms.http.post(url, JSON.stringify(that.newProjectForm), {
                    headers: {
                        'Content-Type': 'application/json'
                    }
                }).then(function (res) {
                    that.submitLoading = false;
                    if (res.result) {
                        that.$notify.success({
                            title: '成功',
                            message: '项目信息添加成功'
                        });
                        that.closeAddDataDialog();
                        // 如果当前正在查看专家的关联信息，刷新关联数据
                        if (that.expertCode) {
                            that.queryRelations();
                        }
                    } else {
                        that.$notify.error({
                            title: '错误',
                            message: res.msg || '添加失败'
                        });
                    }
                }).catch(function(err) {
                    that.submitLoading = false;
                    that.$notify.error({
                        title: '错误',
                        message: '添加失败：' + err
                    });
                });
            },
            submitCompanyData: function() {
                // 实现提交企业数据的逻辑
                var that = this;
                var url = ms.manager + "/expertmanage/relation/addCompany";
                
                ms.http.post(url, JSON.stringify(that.newCompanyForm), {
                    headers: {
                        'Content-Type': 'application/json'
                    }
                }).then(function (res) {
                    that.submitLoading = false;
                    if (res.result) {
                        that.$notify.success({
                            title: '成功',
                            message: '企业信息添加成功'
                        });
                        that.closeAddDataDialog();
                        // 如果当前正在查看专家的关联信息，刷新关联数据
                        if (that.expertCode) {
                            that.queryRelations();
                        }
                    } else {
                        that.$notify.error({
                            title: '错误',
                            message: res.msg || '添加失败'
                        });
                    }
                }).catch(function(err) {
                    that.submitLoading = false;
                    that.$notify.error({
                        title: '错误',
                        message: '添加失败：' + err
                    });
                });
            },
            // 搜索专家
            searchExperts: function() {
                this.currentPage = 1;
                this.getExperts();
            },
            // 重置搜索
            resetSearch: function() {
                this.searchKeyword = '';
                this.currentPage = 1;
                this.getExperts();
            },
            handleDeleteConfirm: function(row) {
                console.log("删除确认按钮被点击", row.expertCode);
                var that = this;
                
                // 直接显示确认对话框而不使用自定义对话框
                this.$confirm(`确定要删除专家"${row.name}"及其所有关联信息吗？此操作将同时删除该专家本身、关联的项目数据和企业数据，不可恢复！`, '删除确认', {
                    confirmButtonText: '确定删除',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    console.log("用户确认删除", row.expertCode);
                    
                    // 显示加载中
                    const loading = that.$loading({
                        lock: true,
                        text: '正在删除中...',
                        spinner: 'el-icon-loading',
                        background: 'rgba(0, 0, 0, 0.7)'
                    });
                    
                    // 删除专家
                    var url = ms.manager + '/expertmanage/relation/deleteWithRelations';
                    
                    // 使用JSON.stringify确保发送的是原始JSON数据
                    var jsonData = JSON.stringify({expertCode: row.expertCode});
                    
                    // 使用原生fetch API发送JSON请求
                    fetch(url, {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json'
                        },
                        body: jsonData
                    })
                    .then(response => response.json())
                    .then(function(res) {
                        loading.close();
                        
                        if (res.result) {
                            that.$notify({
                                title: '删除成功',
                                message: '已删除专家及其所有关联信息',
                                type: 'success',
                                duration: 3000
                            });
                            
                            // 如果当前查看的就是被删除的专家，则清空关联信息
                            if(that.expertCode === row.expertCode) {
                                that.expertInfo = {};
                                that.relatedProjects = [];
                                that.relatedCompanies = [];
                                that.selectedProject = {};
                                that.selectedCompany = {};
                                that.expertCode = '';
                            }
                            
                            // 刷新专家列表
                            that.getExperts();
                        } else {
                            that.$notify.error({
                                title: '删除失败',
                                message: res.msg || '删除专家信息失败，请稍后重试',
                                duration: 5000
                            });
                        }
                    }).catch(function(err) {
                        loading.close();
                        console.error("删除请求失败", err);
                        that.$notify.error({
                            title: '系统错误',
                            message: '删除过程中发生错误：' + err,
                            duration: 5000
                        });
                    });
                }).catch(() => {
                    console.log("用户取消删除");
                    // 用户取消删除，不做任何操作
                });
            },
            confirmDelete: function() {
                console.log("确认删除", this.expertToDelete.expertCode);
                this.deleteLoading = true;
                var that = this;
                var url = ms.manager + "/expertmanage/relation/deleteWithRelations";
                ms.http.post(url, {expertCode: that.expertToDelete.expertCode}).then(function(res) {
                    that.deleteLoading = false;
                    if (res.result) {
                        that.$notify({
                            title: '删除成功',
                            message: '已删除专家及其所有关联信息',
                            type: 'success',
                            duration: 3000
                        });
                        that.deleteConfirmVisible = false;
                        
                        // 如果当前查看的就是被删除的专家，则清空关联信息
                        if(that.expertCode === that.expertToDelete.expertCode) {
                            that.expertInfo = {};
                            that.relatedProjects = [];
                            that.relatedCompanies = [];
                            that.selectedProject = {};
                            that.selectedCompany = {};
                            that.expertCode = '';
                        }
                        
                        // 刷新专家列表
                        that.getExperts();
                    } else {
                        that.$notify.error({
                            title: '删除失败',
                            message: res.msg || '删除专家信息失败，请稍后重试',
                            duration: 5000
                        });
                        that.deleteConfirmVisible = false;
                    }
                }).catch(function(err) {
                    that.deleteLoading = false;
                    that.$notify.error({
                        title: '系统错误',
                        message: '删除过程中发生错误：' + err,
                        duration: 5000
                    });
                    that.deleteConfirmVisible = false;
                });
            },
            // 显示技术领域详情
            showTechnologyDetails: function(techDetails) {
                var html = '<div style="padding: 10px;">' +
                    '<h3 style="margin-bottom: 15px; color: #409EFF; border-bottom: 1px solid #EBEEF5; padding-bottom: 10px;">' + 
                    techDetails.name + ' - 技术领域详情</h3>';
                
                if (techDetails.relatedProjects && techDetails.relatedProjects.length > 0) {
                    html += '<h4 style="margin: 10px 0; color: #606266;">相关项目：</h4>' +
                    '<ul style="padding-left: 20px; margin: 5px 0 15px 0;">';
                    
                    techDetails.relatedProjects.forEach(function(project) {
                        html += '<li style="margin: 5px 0;"><span style="color: #303133; font-weight: 500;">' + 
                            project.projectName + '</span> (项目编码: ' + project.projectCode + ')</li>';
                    });
                    
                    html += '</ul>';
                }
                
                if (techDetails.relatedCompanies && techDetails.relatedCompanies.length > 0) {
                    html += '<h4 style="margin: 10px 0; color: #606266;">相关企业：</h4>' +
                    '<ul style="padding-left: 20px; margin: 5px 0;">';
                    
                    techDetails.relatedCompanies.forEach(function(company) {
                        html += '<li style="margin: 5px 0;"><span style="color: #303133; font-weight: 500;">' + 
                            company.companyName + '</span> (企业编码: ' + company.companyCode + ')</li>';
                    });
                    
                    html += '</ul>';
                }
                
                html += '</div>';
                
                // 使用Element UI的通知显示详情
                this.$notify({
                    title: '技术领域详情',
                    message: html,
                    dangerouslyUseHTMLString: true,
                    duration: 0,
                    position: 'right',
                    customClass: 'relation-details-notification'
                });
            },
            
            // 显示学科领域详情
            showDisciplineDetails: function(disciplineDetails) {
                var html = '<div style="padding: 10px;">' +
                    '<h3 style="margin-bottom: 15px; color: #409EFF; border-bottom: 1px solid #EBEEF5; padding-bottom: 10px;">' + 
                    disciplineDetails.name + ' - 学科领域</h3>' +
                    '<p style="margin-bottom: 15px; color: #606266;">' + disciplineDetails.description + '</p>';
                
                // 添加与专家的关联信息
                if (this.expertInfo.firstLevelDiscipline === disciplineDetails.name || 
                    this.expertInfo.secondLevelDiscipline === disciplineDetails.name) {
                    html += '<div style="margin-top: 10px; padding: 10px; background-color: #f0f9eb; border-radius: 4px;">' +
                        '<strong>专家学科关联：</strong> 专家 ' + this.expertInfo.name + 
                        (this.expertInfo.firstLevelDiscipline === disciplineDetails.name ? ' 的一级学科' : ' 的二级学科') +
                        '</div>';
                }
                
                html += '</div>';
                
                this.$notify({
                    title: '学科领域详情',
                    message: html,
                    dangerouslyUseHTMLString: true,
                    duration: 0,
                    position: 'right',
                    customClass: 'relation-details-notification'
                });
            },
            
            // 显示行业详情
            showIndustryDetails: function(industryDetails) {
                var html = '<div style="padding: 10px;">' +
                    '<h3 style="margin-bottom: 15px; color: #409EFF; border-bottom: 1px solid #EBEEF5; padding-bottom: 10px;">' + 
                    industryDetails.name + ' - 行业详情</h3>';
                
                if (industryDetails.relatedCompanies && industryDetails.relatedCompanies.length > 0) {
                    html += '<h4 style="margin: 10px 0; color: #606266;">相关企业：</h4>' +
                    '<ul style="padding-left: 20px; margin: 5px 0;">';
                    
                    industryDetails.relatedCompanies.forEach(function(company) {
                        html += '<li style="margin: 5px 0;"><span style="color: #303133; font-weight: 500;">' + 
                            company.companyName + '</span> (' + company.industryLevel + ', 编码: ' + company.companyCode + ')</li>';
                    });
                    
                    html += '</ul>';
                }
                
                html += '</div>';
                
                this.$notify({
                    title: '行业详情',
                    message: html,
                    dangerouslyUseHTMLString: true,
                    duration: 0,
                    position: 'right',
                    customClass: 'relation-details-notification'
                });
            },
            
            // 显示通用详情对话框
            showGenericDetails: function(entityDetails, title, type) {
                var html = '<div style="padding: 10px;">' +
                    '<h3 style="margin-bottom: 15px; color: #409EFF; border-bottom: 1px solid #EBEEF5; padding-bottom: 10px;">' + 
                    title + '</h3>';
                
                if (type === 'cooperationExpert') {
                    html += '<p style="margin-bottom: 10px;"><strong>专家编号：</strong>' + entityDetails.expertCode + '</p>' +
                        '<p style="margin-bottom: 10px;"><strong>专家姓名：</strong>' + entityDetails.name + '</p>';
                    
                    if (entityDetails.relationProjects && entityDetails.relationProjects.length > 0) {
                        html += '<h4 style="margin: 10px 0; color: #606266;">共同参与的项目：</h4>' +
                        '<ul style="padding-left: 20px; margin: 5px 0;">';
                        
                        entityDetails.relationProjects.forEach(function(project) {
                            html += '<li style="margin: 5px 0;"><span style="color: #303133; font-weight: 500;">' + 
                                project.projectName + '</span> (角色: ' + project.role + ')</li>';
                        });
                        
                        html += '</ul>';
                    }
                }
                
                html += '</div>';
                
                this.$notify({
                    title: title,
                    message: html,
                    dangerouslyUseHTMLString: true,
                    duration: 0,
                    position: 'right',
                    customClass: 'relation-details-notification',
                    onClose: function() {
                        // 关闭通知时取消高亮
                        if (this.chartInstance) {
                            this.chartInstance.dispatchAction({
                                type: 'downplay'
                            });
                        }
                    }.bind(this)
                });
            },
            searchCompany: function() {
                this.companyLoading = true;
                var that = this;
                var url = ms.manager + "/expertmanage/company/list";
                var params = new URLSearchParams();
                params.append('pageNum', that.companyPagination.pageNo);
                params.append('pageSize', that.companyPagination.pageSize);
                if (that.companySearchKeyword) {
                    params.append('keyword', that.companySearchKeyword);
                }
                
                ms.http.get(url + "?" + params.toString()).then(function (res) {
                    that.companyLoading = false;
                    if (res.result && res.data) {
                        that.companyList = res.data.records || [];
                        that.companyPagination.total = res.data.total || 0;
                    } else {
                        that.$notify.error({
                            title: '错误',
                            message: res.msg || '获取企业列表失败'
                        });
                    }
                }).catch(function(err) {
                    that.companyLoading = false;
                    that.$notify.error({
                        title: '错误',
                        message: '获取企业列表失败：' + err
                    });
                });
            },
            resetCompanySearch: function() {
                this.companySearchKeyword = '';
                this.companyPagination.pageNo = 1;
                this.searchCompany();
            },
            handleCompanySizeChange: function(size) {
                this.companyPagination.pageSize = size;
                this.searchCompany();
            },
            handleCompanyCurrentChange: function(page) {
                this.companyPagination.pageNo = page;
                this.searchCompany();
            },
            editCompany: function(row) {
                this.currentCompany = row;
                this.editCompanyDialogVisible = true;
            },
            deleteCompany: function(row) {
                this.deleteItemDialogVisible = true;
                this.deleteItemType = 'company';
                this.currentCompany = row;
            },
            confirmDeleteItem: function() {
                this.deleteItemLoading = true;
                var that = this;
                
                var url = "";
                var data = {};
                
                if (this.deleteItemType === 'company') {
                    url = ms.manager + "/expertmanage/company/delete/" + that.currentCompany.companyCode;
                } else if (this.deleteItemType === 'expert') {
                    url = ms.manager + "/expertmanage/expert/delete/" + that.currentExpert.expertCode;
                } else if (this.deleteItemType === 'project') {
                    url = ms.manager + "/expertmanage/project/deleteByCode/" + that.currentProject.projectCode;
                }
                
                ms.http.post(url).then(function(res) {
                    that.deleteItemLoading = false;
                    if (res.result) {
                        that.$notify({
                            title: '删除成功',
                            message: '已删除相关信息',
                            type: 'success',
                            duration: 3000
                        });
                        that.deleteItemDialogVisible = false;
                        
                        // 刷新相应的列表
                        if (that.deleteItemType === 'company') {
                            that.searchCompany();
                        } else if (that.deleteItemType === 'expert') {
                            that.searchExpert();
                        } else if (that.deleteItemType === 'project') {
                            that.searchProject();
                        }
                    } else {
                        that.$notify.error({
                            title: '删除失败',
                            message: res.msg || '删除信息失败，请稍后重试',
                            duration: 5000
                        });
                        that.deleteItemDialogVisible = false;
                    }
                }).catch(function(err) {
                    that.deleteItemLoading = false;
                    that.$notify.error({
                        title: '系统错误',
                        message: '删除过程中发生错误：' + err,
                        duration: 5000
                    });
                    that.deleteItemDialogVisible = false;
                });
            },
            saveCompany: function() {
                this.saveLoading = true;
                var that = this;
                var url = ms.manager + "/expertmanage/company/update";
                ms.http.post(url, that.currentCompany).then(function (res) {
                    that.saveLoading = false;
                    if (res.result) {
                        that.$notify.success({
                            title: '成功',
                            message: '企业信息更新成功'
                        });
                        that.editCompanyDialogVisible = false;
                        that.searchCompany();
                    } else {
                        that.$notify.error({
                            title: '错误',
                            message: res.msg || '更新失败'
                        });
                    }
                }).catch(function(err) {
                    that.saveLoading = false;
                    that.$notify.error({
                        title: '错误',
                        message: '更新失败：' + err
                    });
                });
            },
            searchExpert: function() {
                this.expertLoading = true;
                var that = this;
                var url = ms.manager + "/expertmanage/expert/list";
                var params = new URLSearchParams();
                if (that.expertSearchKeyword) {
                    params.append('keyword', that.expertSearchKeyword);
                }
                // 使用params数组参数传递页码和每页大小
                params.append('params', that.expertPagination.pageNo);
                params.append('params', that.expertPagination.pageSize);
                
                ms.http.get(url + "?" + params.toString()).then(function (res) {
                    that.expertLoading = false;
                    if (res.result && res.data) {
                        that.expertManageList = res.data.records || [];
                        that.expertPagination.total = res.data.total || 0;
                    } else {
                        that.$notify.error({
                            title: '错误',
                            message: res.msg || '获取专家列表失败'
                        });
                    }
                }).catch(function(err) {
                    that.expertLoading = false;
                    that.$notify.error({
                        title: '错误',
                        message: '获取专家列表失败：' + err
                    });
                });
            },
            resetExpertSearch: function() {
                this.expertSearchKeyword = '';
                this.expertPagination.pageNo = 1;
                this.searchExpert();
            },
            handleExpertSizeChange: function(size) {
                this.expertPagination.pageSize = size;
                this.searchExpert();
            },
            handleExpertCurrentChange: function(page) {
                this.expertPagination.pageNo = page;
                this.searchExpert();
            },
            editExpertInfo: function(row) {
                this.currentExpert = row;
                this.editExpertDialogVisible = true;
            },
            deleteExpertInfo: function(row) {
                this.deleteItemDialogVisible = true;
                this.deleteItemType = 'expert';
                this.currentExpert = row;
            },
            saveExpert: function() {
                this.saveLoading = true;
                var that = this;
                var url = ms.manager + "/expertmanage/expert/update";
                ms.http.post(url, that.currentExpert).then(function (res) {
                    that.saveLoading = false;
                    if (res.result) {
                        that.$notify.success({
                            title: '成功',
                            message: '专家信息更新成功'
                        });
                        that.editExpertDialogVisible = false;
                        that.searchExpert();
                    } else {
                        that.$notify.error({
                            title: '错误',
                            message: res.msg || '更新失败'
                        });
                    }
                }).catch(function(err) {
                    that.saveLoading = false;
                    that.$notify.error({
                        title: '错误',
                        message: '更新失败：' + err
                    });
                });
            },
            searchProject: function() {
                this.projectLoading = true;
                var that = this;
                var url = ms.manager + "/expertmanage/project/list";
                var params = new URLSearchParams();
                params.append('pageNum', that.projectPagination.pageNo);
                params.append('pageSize', that.projectPagination.pageSize);
                if (that.projectSearchKeyword) {
                    params.append('keyword', that.projectSearchKeyword);
                }
                
                ms.http.get(url + "?" + params.toString()).then(function (res) {
                    that.projectLoading = false;
                    if (res.result && res.data) {
                        that.projectList = res.data.records || [];
                        that.projectPagination.total = res.data.total || 0;
                    } else {
                        that.$notify.error({
                            title: '错误',
                            message: res.msg || '获取项目列表失败'
                        });
                    }
                }).catch(function(err) {
                    that.projectLoading = false;
                    that.$notify.error({
                        title: '错误',
                        message: '获取项目列表失败：' + err
                    });
                });
            },
            resetProjectSearch: function() {
                this.projectSearchKeyword = '';
                this.projectPagination.pageNo = 1;
                this.searchProject();
            },
            handleProjectSizeChange: function(size) {
                this.projectPagination.pageSize = size;
                this.searchProject();
            },
            handleProjectCurrentChange: function(page) {
                this.projectPagination.pageNo = page;
                this.searchProject();
            },
            editProject: function(row) {
                this.currentProject = row;
                this.editProjectDialogVisible = true;
            },
            deleteProject: function(row) {
                this.deleteItemDialogVisible = true;
                this.deleteItemType = 'project';
                this.currentProject = row;
            },
            saveProject: function() {
                this.saveLoading = true;
                var that = this;
                var url = ms.manager + "/expertmanage/project/update";
                ms.http.post(url, that.currentProject).then(function (res) {
                    that.saveLoading = false;
                    if (res.result) {
                        that.$notify.success({
                            title: '成功',
                            message: '项目信息更新成功'
                        });
                        that.editProjectDialogVisible = false;
                        that.searchProject();
                    } else {
                        that.$notify.error({
                            title: '错误',
                            message: res.msg || '更新失败'
                        });
                    }
                }).catch(function(err) {
                    that.saveLoading = false;
                    that.$notify.error({
                        title: '错误',
                        message: '更新失败：' + err
                    });
                });
            },
            showManagementDialog: function() {
                // 跳转到管理页面
                window.location.href = ms.manager + "/expertmanage/relation/management";
            }
        },
        created: function () {
            // 初始化分页参数，确保数据类型正确
            this.currentPage = 1;
            this.pageSize = 10;
            this.jumpPage = 1;
            this.total = 0;
            
            // 获取专家列表数据
            this.getExperts();
            
            // 从URL参数中获取expertCode
            var urlParams = new URLSearchParams(window.location.search);
            var expertCodeParam = urlParams.get('expertCode');
            
            // 如果URL中包含expertCode参数，自动执行关联查询
            if (expertCodeParam) {
                this.expertCode = expertCodeParam;
                this.queryRelations();
            }
            
            // 添加窗口大小变化监听器
            window.addEventListener('resize', this.handleResize);
        },
        
        mounted: function() {
            // 初始化计算表格高度
            this.calculateTableHeight();
        },
        
        beforeDestroy: function() {
            // 移除窗口大小变化监听器
            window.removeEventListener('resize', this.handleResize);
        }
    });
</script>
</body>
</html> 